By Parisa Hafezi
TEHRAN (Reuters) - Two U.S. citizens sentenced in Iran to eight years' jail for spying flew out of the country on Wednesday after Oman paid bail of $1 million, diplomats said.
Josh Fattal and Shane Bauer, who were arrested while hiking along the Iraq-Iran border in 2009 and denied being spies, flew initially to Oman, whose officials helped secure their release.
"Two years is too long in a prison," Bauer said in a brief statement on behalf of the two. "We sincerely hope for the freedom of other political prisoners and other unjustly imprisoned people in America and in Iran."
The release was announced last week by President Mahmoud Ahmadinejad, who said it would be a humanitarian gesture before his annual trip to the U.N. General Assembly in New York.
Ahmadinejad told U.S. media that the men would be let go "in a couple of days." But Iran's judiciary, controlled by rival conservative hardliners, immediately and publicly contradicted him by ruling out an imminent release.
In the event, the men's departure on the eve of his speech to the assembly could hardly have been better for Ahmadinejad as he tries to improve his image with the U.S. public.
U.S. President Barack Obama said he was "thrilled" that Iran had released the two men.
"It was the right thing to do. They shouldn't have been held in the first place," Obama told reporters on the sidelines of the United Nations General Assembly
Bauer and Fattal were arrested on July 31, 2009, near Iran's border with Iraq along with a third American, Sarah Shourd. The trio, in their late 20s and early 30s, said they were on a hiking holiday.
Shourd was released on the same $500,000 bail a year ago and allowed to fly home, but the two men were sentenced to eight years in prison last month after a trial held behind closed doors.
The official IRNA news agency quoted the pair's lawyer as saying Oman had paid the bail for the two men.
"I am happy. They were my clients. We tried for nearly two years and gained the results we wanted," the pair's lawyer Masoud Shafie told reporters.
Washington denied that any of the group were spies. Their supporters say no evidence against them was ever made public.
With no diplomatic relations between Washington and Tehran since the 1979 Islamic Revolution, several countries tried to resolve the impasse.
In addition to Oman, Iraqi President Jalal Talabani also helped to mediate, Iraqi officials said.
The Swiss embassy was also involved, but the ambassador, Livia Leu Agosti, was not allowed to enter Tehran's Evin prison and had to wait in her car for the men's release.
Shafie said the release had been delayed twice because a judge whose signature was required was away on vacation -- another hint that Ahmadinejad's rivals within the fractious ruling elite might have aimed to embarrass him.
Oman's Foreign Ministry thanked Iranian Supreme Leader Ayatollah Ali Khamenei and the Iranian government for "responding with humanitarian considerations and to efforts of the sultanate's government," the Omani state news agency ONA reported.
(Additional reporting by Ramin Mostafavi, Hossein Jaseb and Sanam Shantyaei; Writing by Parisa Hafezi and Myra MacDonald)