Iran charged three Americans it captured in July near the border with Iraq with espionage on Monday, prompting Washington to demand the release of what it says are innocent hikers.

Tehran's chief prosecutor Abbas Jaffari Doulatabadi said investigations were continuing against the trio, Shane Bauer, 27, Sarah Shourd, 31, and Josh Fattal, 27, the official IRNA news agency reported.

A statement on their case is to be made in the near future.

"The three Americans arrested near the border of Iran and Iraq are facing charges of spying and the inquiry is continuing," he said.

The United States called for the swift release of the three, insisting they were wrongly detained.

"If it is true that they have been formally charged, we would find this outrageous. And, of course, the families would find it devastating," US State Department spokesman Ian Kelly said.

At the White House, spokesman Robert Gibbs said the three were "innocent young people, who should be released by the Iranian government. Their release should be expedited."

But Iranian President Mahmoud Ahmadinejad insisted that justice needed to run its course.

"There are rules in every country that punish illegal entry to its territory. It is an obligation to respond to such an event," he told a news conference in Istanbul where he was attending a meeting of the Organisation of the Islamic Conference.

Asked about the espionage charges being levelled against the trio, he said that was entirely a matter for the courts.

"I have no opinion," he said. "It is the judges who know whether they are spies or not."

Family and friends of the three have said they were in a mountainous border region in northern Iraq near a famous waterfall when they unintentionally strayed into Iran.

"The allegation that our loved ones may have been engaged in espionage is untrue," the families said in a joint statement.

"It is entirely at odds with the people Shane, Sarah and Josh are and with anything that Iran can have learned about them since they were detained on July 31.

"This has already gone on for too long."

US Secretary of State Hillary Clinton said there was no evidence for Iran to charge the three.

"We believe strongly that there is no evidence to support any charge whatsoever," Clinton told reporters during a visit to Germany to join celebrations commemorating the fall of the Berlin Wall.

"And we would renew our request on the behalf of these three young people and their families that the Iranian government exercise compassion and release them so they can return home."

A friend of the trio, who had travelled with them to Iraq for the hike and would have been with them at the time of their arrest but for a bout of illness, appealed to Ahmadinejad last week to free them as soon as possible.

"Mr President, by continuing to deprive Shane, Sarah and Josh of their liberty, Iran is working against some of the very causes it supports," Shon Meckfessel wrote.

"Each of these three has a long and public record of contesting injustice in the world and addressing some of the inequities between rich and poor which you have spoken about through their humanitarian work in their own country and overseas."

A Swiss diplomat visited the three Americans in Iran's notorious Evin prison last month, according to their families, who said the trio were "in good physical shape."

Switzerland has looked after US interests in Iran since Washington and Tehran broke off diplomatic relations following the seizure of the US embassy by radical students in the aftermath of the Islamic revolution of 1979.

"We've been assured by the Swiss that they have not been mistreated," said Fattal's brother, Alex, adding that the families remained concerned about the psychological toll of their prolonged detention.

Friends and relatives held vigils to mark their 100th day in custody. The vigils last Sunday were called in 10 US states and eight countries.