BAGHDAD - The Iranian ambassador in Baghdad said the recent release of two Iranians from Iraqi custody was not an indication of any impending deal to free three Americans held by Tehran on spying charges.

Ambassador Hassan Kazemi Qomi told the Associated Press that the fate of the Americans, who have been held since July, was in the hands of the Iranian judiciary and had no connection to the release of two Iranians last month.

"There were no deals," Qomi said. "They [Americans] are in the custody of the judiciary system."

The detained Americans - Sarah Shourd, 31; her boyfriend, Shane Bauer, 27; and their friend Josh Fattal, 27, whose family lives in Elkins Park - were arrested along the Iraqi border. Iran has accused them of espionage, but their families say the three were hiking in northern Iraq's mountainous Kurdish region and if they strayed into Iran, it was unintentional.

In a goodwill gesture by Iran, their mothers were allowed to visit them in May for the first time since they were taken into Iranian custody.

The visit, along with the release by Baghdad of two Iranians held for years in U.S. and later Iraqi custody, raised the possibility of a behind-the-scenes swap for the Americans' freedom.

The option came into focus especially after Iranian leaders suggested a link between the American hikers and a number of Iranians held by the United States whom Tehran would like to see released.

During an interview with the AP at the Iranian Embassy in Baghdad late Sunday, Qomi discussed the case of the three Americans.

"The families came and visited them," he said. "The judiciary system has a fair position on this matter. We hope that their issue will be solved."

The Americans' detention comes at an increasingly tense period between Iran and the West, concerned over Iran's refusal to stop its uranium enrichment. The United States has also often accused Tehran of meddling in Iraq, particularly by financing Shiite militias that frequently attacked American troops here.