TEHRAN, Iran – Iran’s foreign minister said Saturday that the courts are willing in “the near future” to commute the prison sentences for two Americans convicted of spying.

The Americans’ attorney, meanwhile, was in court trying to arrange a $1 million bail-for-freedom deal.

The release rests in the hands of the hard-line judiciary, and Foreign Minister Ali Akbar Salehi gave no clear timetable. He also raised the issue of Iranians held in U.S. prisons, suggesting the Americans’ release might be drawn out to bring attention to inmates Iran wants freed.

In a case that has added to the acrimony between Iran and the United States, Shane Bauer and Josh Fattal, both 29, were detained along the Iran-Iraq border in July 2009 with their friend Sarah Shourd. The Americans say they may have mistakenly crossed into Iran while hiking in the semiautonomous Kurdish region of northern Iraq.

Shourd was released last September with mediation by the Gulf nation of Oman after $500,000 was paid.

The two men were convicted of illegally entering Iran and spying for the United States, and were sentenced to a total of eight years in prison each.

They denied the charges and appealed the verdicts, opening the way for the possible deal to free them in exchange for $500,000 bail each.

Salehi said that Iran’s judiciary was ready to commute the sentences as a gesture of Islamic mercy. But he did not give any clearer indication of when they could be released.

“The judiciary’s decision is to commute (the Americans’) punishment,” the foreign minister said. “We expect the judiciary to make its decision in the near future.”

“We hope this issue will be finalized so that both families of Iranians who are waiting (for inmates in U.S. prisons) as well as the families of these U.S. nationals will, God willing, hear good news,” Salehi said.