President Mahmud Ahmadinejad said in interviews Tuesday that Iran would release two US hikers jailed for spying in a couple of days on bail which their lawyer said had been set at $500,000 each.

"I am helping to arrange for their release in a couple of days so they will be able to return home. This is of course going to be a unilateral humanitarian gesture," Ahmadinejad told The Washington Post.

"It is a unilateral pardon" of the hikers, he added.

In a separate interview with US network NBC News, Ahmadinejad said Shane Bauer and Josh Fattal would be released "in two days" but their lawyer Masoud Shafii told AFP that they would be freed only when bail had been paid.

The pair, who were detained in 2009, were both sentenced to eight years in jail last month on charges of espionage and illegal entry in a case that has further strained relations between Washington and Tehran.

"The Americans will be freed when the bail is paid," their lawyer told AFP, adding that the judiciary had informed him of its decision in the middle of the day Tuesday and that he had yet to contact their families.

Asked by the Post how the pair would return to the US, Ahmadinejad said that "they are free to choose".

Bauer and Fattal, were arrested near the mountainous Iraq-Iran border in July 31, 2009, along with a third hiker, Sarah Shourd, who was granted bail on humanitarian and medical grounds and allowed to leave the country in September last year.

Her bail too was set at $500,000 and was paid through Oman, a US Gulf ally that maintains relations with Iran.

Shafii announced late last month that he had lodged an appeal against his clients' conviction.

"I believe that my clients are innocent so if the appeals judges look at the case within a legal framework, and show compassion," the pair could be freed, he said at the time.

The trio have consistently maintained that they innocently strayed across the unmarked border with Iran while hiking in Iraq's northern Kurdistan region.

The jailing of Bauer and Fattal sparked anger in Washington which already has deep differences with Tehran over its controversial nuclear programme, its refusal to recognise Israel and its support for militant groups across the Middle East.

US President Barack Obama regarded the jail terms handed down against the pair as "an abomination," a top White House diplomatic nominee said last week.

"The administration quite agrees with you that this is an abomination, that these hikers do not belong in prison," and that they "ought to be released immediately," Wendy Sherman told the US Senate Foreign Relations Committee at a confirmation hearing to become the State Department's number three.

US Secretary of State Hillary Clinton "believes that we must take every opportunity we can to push this, to work with the Swiss protecting authority, which represents us in Iran, to try to get consular access to them, to push for their release," said Sherman.

Washington and Tehran have had no diplomatic relations since the aftermath of the Islamic revolution of 1979 when Islamist students seized the US embassy ion Tehran.

Its interests in Iran are looked after by the Swiss embassy.

The Swiss mission said on Tuesday it was not immediately able to confirm the Iranian judiciary's decision.