Lawyer Masoud Shafiei said the court would begin the process to free Shane Bauer and Josh Fattal after payment of the bail, which must be arranged through third parties because of U.S. economic sanctions on Iran. But the timing of the court's decision is similar to last year's bail deal mediated by the Gulf state of Oman that freed a third American, Sarah Shourd.
"They accepted to set bail to release," Shafiei told The Associated Press after leaving the court. "The amount is the same for Sarah."
Iranian President Mahmoud Ahmadinejad, in an interview aired on NBC's "Today" show, predicted the Americans could be freed "in a couple of days." He described the bail offer as a "humanitarian gesture" and repeated complaints about attention for Iranians held in U.S. prisons.
In Washington, U.S. Secretary of State Hillary Rodham Clinton said the United States was "encouraged" by Ahmadinejad's comments.
"We obviously hope that we will see a positive outcome from what appears to be a decision by the government," Clinton told reporters at the State Department.
The Americans were arrested in July 2009 along the Iran-Iraq border and accused by Iran of espionage. The trio have denied the charges and say they may have mistakenly crossed into Iran when they stepped off a dirt road while hiking near a waterfall in the Kurdish region of Iraq.
Last month, Bauer and Fattal, both 29, were sentenced to three years each for illegal entry into Iran and five years each for spying for the United States. They appealed the verdicts. Shourd's case remains open.
Shafiei said he has passed along details of the court's decision to the Swiss Embassy, which represent U.S. interests in Iran since there are no diplomatic relations between Tehran and Washington.
State Department spokeswoman Victoria Nuland said officials were in touch with Swiss envoys "to get more details from the Iranian authorities."
Iran may have timed the court decision to coincide with Ahmadinejad's visit later this month to New York for the general assembly of the United Nations. Last year, Shourd was released on bail just as Ahmadinejad was heading for the annual gathering of world leaders.
But Ahmadinejad was not likely involved closely in any decisions on the case. Iran's judiciary is controlled by the country's ruling clerics, who have been waging relentless pressure on Ahmadinejad and his allies as part of an internal power struggle.
The diplomatic pathways for possible bail payments was not immediately clear. Officials in Oman — which has close ties with the U.S. and Iran — did not immediately respond for comment on whether they could again offer assistance.
The prime minister of Pakistan, which handles Iran's diplomatic interests in the U.S., has been in Iran since Sunday. But there has been no indication that Yousef Raza Gilani is playing any role in the case.
The possible release of the two Americans would remove one point of tension between Iran and the United States, but massive suspicions still exist on both sides and no thaw is in sight.
Washington and European allies worry Iran is using its civilian nuclear program as cover to develop atomic weapons and have urged for even stronger sanctions to pressure Tehran. Iran denies any efforts to make nuclear weapons.
Iranian officials, meanwhile, is deeply concerned about the U.S. military on its borders in Iraq and Afghanistan, and sharply denounces U.S. influence in the Middle East.
Fattal's mother, Laura Fattal, of Elkins Park, Pennsylvania, told the AP that she could not comment on the court decision. There was no immediate comment from Bauer's family.
Shourd is living in Oakland, California; Fattal is from suburban Philadelphia and Bauer — who proposed marriage to Shourd while in prison — grew up in Onamia, Minnesota.
The last direct contact family members had with Bauer and Fattal was in May 2010 when their mothers were permitted a short visit in Tehran.
Their case most closely parallels that of freelance journalist Roxana Saberi, an Iranian-American who convicted of spying before being released in May 2009. Saberi was sentenced to eight years in prison, but an appeals court reduced that to a two-year suspended sentence and let her return to the U.S.
At the time, a spokesman for the Iranian judiciary said the court ordered the reduction as a gesture of "Islamic mercy" because Saberi had cooperated with authorities and expressed regret.
In May 2009, a French academic, Clotilde Reiss, also was freed after her 10-year sentence on espionage-related charges was commuted.
Last year, Iran freed an Iranian-American businessman, Reza Taghavi, was held for 29 months for alleged links to a bombing in the southern city of Shiraz, which killed 14 people. Taghavi denied any role in the attack.
Associated Press writers Patrick Walters in Philadelphia and Matthew Lee in Washington contributed to this report.