New York (CNN Business) Political and economic realities could make it difficult for President Donald Trump to carry out his threat to punish Iraq with bruising sanctions if US troops are expelled from the country.

Trump vowed Sunday to hit Iraq with penalties "like they've never seen before" if American troops are forced out on an unfriendly basis.

"It'll make Iranian sanctions look somewhat tame," the president told reporters aboard Air Force One.

That would be difficult to achieve without lifting already-rising oil and gasoline prices. Iraq is one of the most important oil producers on the planet. Sidelining Iraq's output would exacerbate fears of a supply shock that erupted after Trump ordered the drone strike in Baghdad last week that killed a top Iranian commander.

"If there were Iran-style sanctions that made Iraq's oil toxic to the rest of the world, that would drive prices up quite sharply," said Bob McNally, president of consulting firm Rapidan Energy Group.

That's exactly why analysts don't believe Trump will follow through on his threat, especially with the presidential election only 10 months off. He made the statement after the Iraqi parliament voted Sunday to obligate its government to work towards ending the presence of all foreign troops on Iraqi soil.

"It would be really bullish for gas prices and therefore hurt the economy and Trump's election chances," McNally said.

Iraq is the No. 2 oil producer within OPEC, behind only Saudi Arabia. Iraq produced 4.6 million barrels of crude per day in November, well above the 3.1 million barrels produced by the United Arab Emirates, the No. 3 player in OPEC.

Bigger picture, Iraq is expected to be the third-largest contributor to global oil supply through 2030, according to the International Energy Agency.

The United States relies on Iraqi oil to keep the American economy humming. US oil imports from Iraq totaled 252,000 barrels per day in October, according to the most recent US government stats. That makes Iraq the No. 4 source of foreign oil to the United States, behind Canada, Mexico and Saudi Arabia.

"Who can predict what Trump is going to do next? But it doesn't make a great deal of sense," said Matt Smith, director of commodity research at Clipper Data.

OPEC has room to pump more oil to offset losses from Iraq or elsewhere. The cartel, along with allies like Russia, has been restraining production in a bid to boost prices.

However, McNally said OPEC wouldn't be able to compensate for the loss of all of Iraq's production. "We'd be out of spare capacity."

To be sure, Trump did not specifically mention that US sanctions would target Iraq's oil industry. However, oil is clearly Iraq's most important industry. Oil exports, excluding ones made by the semi-autonomous Kurdistan Regional Government in the north, accounted for 88% of total government revenue in 2017, according to the US Energy Information Administration

In other words, it would be hard to severely punish Iraq without touching its oil industry.

Shale revolution reduces America's foreign oil needs

US presidents typically try to avoid taking action that causes pain at the pump. The national average price of gasoline is $2.58 a gallon, roughly flat with a month ago, according to AAA . However, a sudden rise above $3 a gallon could upset voters ahead of the November election, and a sustained spike in energy prices would slow parts of the American economy.

"President Trump is clearly bound by the election dynamics to ensure the markets are supported and the economy does not suffer an oil shock," said Matt Gertken, a geopolitical strategist at BCA Research.

However, Trump likely isn't as worried as his predecessors were about an oil shock. That's because the US is now the world's leading oil producer, lessening its reliance on foreign crude. In fact, the shale revolution has left America with so much oil that it is now exporting millions of barrels a day.

Net imports (imports minus exports) stood at just 2.9 million barrels per day in October, according to the most recent Energy Information Administration statistics. That's down dramatically from 8.7 million a decade earlier.

"President Trump feels he has a buffer with voters over gasoline prices. That has emboldened him to put pressure on Iran," said Gertken.

Rob Thummel, managing director at energy investment firm Tortoise Capital, said America's shale oil boom would limit the long-term impact of US sanctions on Iraq.

"The US could produce more oil if it had to. It would take a little while because oil production is not like turning on your faucet. It takes time," said Thummel.

Repeat of Iran in 2018?

Still, in the past Trump has displayed concerns about how oil sanctions will impact the American economy.

In 2018, oil prices soared after he promised to zero out Iran's oil exports through sanctions.

"If we did Iraq sanctions," Rapidan's McNally said, "I think we'd see a repeat of the situation with Iran."