When allegations swirled this week that the administration had paid Iran $400 million in exchange for the release of American hostages, President Obama's message was clear: "We do not pay ransom."

However, American presidents on both sides of the aisle, including Obama himself, have done exactly that in the past, and experts say breaking the prohibition against paying ransoms for hostages is more common than people realize.

"These matters go on all the time, we have people being picked up in the Philippines or other places. We do whatever we can ... but presidents have to make a judgment," said Henry Nau, a professor of political science at the George Washington University.

Most recently, Obama released five Taliban members from Guantanamo Bay in exchange for the return of Army Sgt. Bowe Bergdahl, who had been taken hostage. The swap quickly drew criticism from Congress because lawmakers were not informed of the Gitmo release ahead of time as required by law.

The U.S. government says it does not pay money for the release of hostages, and any government money being spent on ransoms would need to be approved by Congress, experts said. But the Obama administration took steps to loosen this prohibition, announcing last year that it would no longer prosecute families of those captured for raising money and paying a ransom.

The Wall Street Journal reported this week that the Obama administration sent about $400 million in foreign currency to Iran in January, the same day the four American hostages were released. The administration has repeatedly claimed that the payment was part of the settling of a decades-old legal claim, but Republicans have said the link is undeniable.

"We were right in January 2016 to describe the administration's $1.7 billion transfer to Iran as a ransom payment. Paying ransom to kidnappers puts Americans even more at risk," Sen. Mark Kirk, R-Ill., said in a statement.

Nau said that multiple conversations are often ongoing at the same time, and it can be difficult to know how or why two different negotiations become connected.

"The timing suggests that there was clearly a link between the freeing of hostages and the unfreezing of monies that were Iranian monies to begin with," he said.

But Obama is far from the only U.S. president to undertake these types of negotiations. In 2002, President George W. Bush sent $300,000 in private money to the Abu Sayyif rebel group to try to free Martin and Gracia Burnham, two Americans taken hostage while celebrating their wedding anniversary in the Philippines.

Bush also changed the U.S. policy about ransom-paying from a flat out prohibition to one stating that the U.S. government would "deny hostage takers the benefits of ransom, prisoner releases, policy changes, or other acts of concession."

In the famed mid-1980s Iran-Contra scandal, President Ronald Reagan secretly sold arms to Iran to secure the release of American hostages held by Iran, while diverting money from the sale to fund the Contras, a rebel group in Nicaragua.

"Shipping off missiles to Iran for negotiations over the embassy hostages is a pretty good example that people on the Republican side make the same potential deals that the Democrats might," said Tony Cordesman, the Arleigh A. Burke Chair in Strategy at the Center for Strategic and International Studies.

"In the real world, you do whatever is necessary. This isn't a matter of moral or ethical principle. It's a matter of what the pragmatic outcome is," he continued.

The precedent of trading money for hostages dates back to the founding days of our country, according to Which Lessons Matter? American Foreign Policy Decision Making in the Middle East 1979-1987, a book by Christopher Hemmer, dean of the Air War College.

President George Washington gave arms to the Barbary pirates to secure the release of American sailors, according to the book. President Thomas Jefferson, another founding father, also paid a $60,000 ransom to the pirates to bring home more then 300 sailors being held in Tripoli.