The Obama administration quietly shipped $400 million stacked on wooden pallets in an unmarked plane to Iran in January — just as Tehran was releasing four Americans who had been detained there, according to a report.

The huge cash load represented the first payment of a $1.7 billion debt that Iran, at an international tribunal in The Hague, claimed it was owed over a failed 1979 arms deal signed before the fall of Shah Mohammad Reza Pahlavi, according to a report by the Wall Street Journal Tuesday night.

The Obama administration was accused Tuesday night of making the cash-for-hostages deal by timing the payout to the release — but US officials said the money was simply part of settling the nearly 40-year-old debt under the terms of the historic nuclear agreement hammered out in 2015.

“As we’ve made clear, the negotiations over the settlement of an outstanding claim . . . were completely separate from the discussions about returning our American citizens home,” State Department spokesman John Kirby told the Journal.

“Not only were the two negotiations separate, they were conducted by different teams on each side, including, in the case of The Hague claims, by technical experts involved in these negotiations for many years.”

However, US officials did admit that Iran wanted the cash in exchange for the Americans so Tehran could say it got something out of the detainees’ release, according to the Journal.

When President Obama talked about the release on Jan. 17, he said, “With the nuclear deal done, prisoners released, the time was right to resolve this dispute as well.”

But he never mentioned the $400 million ­simultaneous payment.

US prisoners held by Iran included Saeed Abedini, Nosratollah Khosravi, Amir Hekmati, a former Marine, and Washington Post reporter Jason ­Rezaian.

The money was paid in euros and other currency acquired from the central banks of the Netherlands and Switzerland, since making a transaction with Iran in American dollars is illegal under US law.

A GOP opponent of the Iran nuke deal, Sen. Tom Cotton of Arkansas, accused Obama of shelling out “a $1.7 billion ransom to the ayatollahs for US hostages,” the Journal reported.

“This break with long-standing US policy put a price on the head of Americans, and has led Iran to continue its illegal seizures” of Americans, Cotton said.

Former Republican presidential candidate Marco Rubio tweeted the report Tuesday, saying, “Obama administration sent plan[e] load of cash to #Iran as ransom as part of deal on hostages. Just unreal.”

The US has long had a policy against paying ransom for hostages. In 2015, though, the Obama administration relaxed that policy after the seizures of Americans by ISIS, saying it would not prosecute captives’ relatives who wished to pay ransoms on their own. The government, in fact, will even help families communicate with militants.

Observers fear, though, that paying ransom only encourages more hostage-taking for profit.

Since the payment of the $400 million in January, two Iranian-Americans have been held by Iran’s Revolutionary Guard.