The White House dismissed Republican accusations Tuesday that the U.S. paid Iran $1.7 billion as ransom to gain the release of American prisoners, saying the payment settled a long-running claim by Tehran over military equipment.

White House press secretary Josh Earnest said it was “not a coincidence” that the financial issue was settled at the same time as the administration swapped prisoners with Tehran and lifted U.S. economic sanctions in a deal to limit Iran’s nuclear program. But he said the release of the four Americans was not linked to the payment, and instead resulted from “diplomatic opportunities” that arose during the negotiations.

“This is Exhibit A in the administration pursuing tough, principled diplomacy in a way that actually ends up making the American people safer and advancing the interests of the United States more effectively than military action,” Mr. Earnest said.

Republicans have blasted the administration for negotiating with terrorists and endangering Americans abroad in the future by creating incentive among enemies of the U.S. to take more hostages. Sen. Ted Cruz, Texas Republican who’s running for president, said the deal set a “very dangerous precedent” that encourages bad actors to “go capture an American.”

Sen. Marco Rubio of Florida, another GOP presidential candidate, said the swap and payment to Iran has “put a price on the head of every American abroad.” And a spokeswoman for Speaker Paul Ryan, Wisconsin Republican, criticized the administration for paying “ransom” to gain the release of a Christian pastor, a Washington Post reporter and two other Americans who had been held by Iran.

“The successful resolution of our concerns about Iran’s nuclear program created a series of diplomatic opportunities for the United States that we’ve had capitalized on,” he said. “And we used that opening, and we used that deeper diplomatic engagement to secure the release of five American citizens who were being unjustly held inside of Iran.”

The release of a fifth American, a student, was unrelated to the prisoner swap, other officials have said.

Mr. Earnest said the payment last weekend was “a very good deal for taxpayers” because Iran was actually seeking interest payments of up to $7 billion for the decades-old claim.

“Our exposure when it came to paying interest could have been much higher,” Mr. Earnest said.

The U.S. had accepted about $400 million in payment from Iran in a military deal in the 1970s, but the equipment was never delivered to Tehran after the Iranian revolution in 1979, in which Iranians seized the U.S. embassy and held dozens of Americans hostage for 444 days. The money was held in escrow at The Hague.

Asked if the administration was creating incentive for hostage-taking by its enemies in last weekend’s prisoner swap that included seven Iranians held by the U.S., Mr. Earnest said the president’s actions compared favorably with President Reagan in the late 1980s.

“It’s not distant or ancient American history that President Reagan acknowledged on live television that he had traded arms for hostages, and I haven’t heard a lot of Republican criticism of that,” Mr. Earnest said. “Maybe [Republicans] are so reflexively committed to defending those kinds of actions that it’s hard for them to consider what could be gained from this humanitarian release of nonviolent [Iranian] individuals, most of whom were American citizens … to secure the release of innocent Americans by Iran.”

In the prisoner swap, the U.S. released seven Iranians, including six who have dual citizenship in the U.S., who had been charged or convicted of violating a trade embargo to supply Iran with technology, military equipment or industrial parts with possible military applications. Some of those released said they will stay in the U.S.; Mr. Obama granted clemency to all seven.

The U.S. also agreed to drop its pursuit of another 14 Iranians living abroad for alleged violations of the embargo, saying extradition was unlikely.

It’s at least the third time the administration has engaged in high-profile prisoner exchanges that have raised accusations of bargaining with America’s enemies. In 2014, the U.S. obtained the release of Army Sgt. Bowe Bergdahl, who had wandered away from his unit in Afghanistan, in exchange for five Taliban commanders who were being held at the Guantanamo Bay detention facility.

And the U.S. engaged in a spy swap with Cuba in December 2014 that also resulted in the release of American Alan Gross, who had been held prisoner by the communist regime. Mr. Earnest said the release of Mr. Gross was in a different category as a “humanitarian gesture” by the Cuban government, with which the U.S. has restored diplomatic relations.