President Trump often celebrates his unpredictability, declaring that it keeps allies and adversaries alike off balance.

By his telling, his willingness to bomb Iranian nuclear sites 13 months ago, and send Delta Force commandos in to snatch President Nicolás Maduro of Venezuela from his bed in early January, reflected his determination to execute military operations that would have made his predecessors blanch. He told The New York Times he was limited only by “my own morality,” as he wielded the world’s biggest hammer.

But in recent weeks, he has seemed trapped, his presidency gradually consumed by a war he cannot find his way out of.

He has discovered limits on his power that he could have scarcely imagined as he began full combat operations on Feb. 28, when he set out goals for a swift end to Iran’s nuclear program and the overthrow of the country’s government.

Five months later, those goals remain almost entirely unaccomplished. And Mr. Trump, once confident that overwhelming force would enable him to pursue in Iran what he proudly called the “Venezuela model” — a change of government to one amenable to U.S. control — is now hesitant to plunge back into major combat operations that his intelligence agencies assess are unlikely to work as well in Tehran.

He has been unable to control surging oil prices, or their effects on the stock market. The shipping that crawled to a stop in the Strait of Hormuz, then was opened for a few short weeks, is back to a trickle, with a second choke point, between the Red Sea and the Gulf of Aden, now threatened. And while the president has threatened to take Kharg Island, where Iran ships oil, or to seize its underground stores of enriched uranium, he has said publicly that he knows there is no appetite for sending in ground troops.