Updated

After more than two years in custody, the two American hikers jailed as spies in Iran were released on $1 million bail Wednesday and flown out of the country, the state's news agency reported.

The plane carrying the freed hikers has landed in Muscat, Oman. It is unclear how long the men will stay in the Gulf state before heading home to the U.S.

Shane Bauer and Josh Fattal, both 29, who are friends from their days at the University of California at Berkeley, were released into the custody of an Omani delegation.

Their families released a statement thanking the Omani envoy and the Swiss ambassador to Iran among others.

"Today can only be described as the best day of our lives," the statement read. "We have waited for nearly 26 months for this moment and the joy and relief we feel at Shane and Josh's long-awaited freedom knows no bounds."

More On This...

President Obama, meanwhile, "welcomed" the release of the hikers.

"I welcome the release of Shane Bauer and Josh Fattal from detention in Iran and am very pleased that they are being reunited with their loved ones," Obama said in a statement.

Secretary of State Hillary Clinton joined the president in welcoming the hikers' release.

"I am grateful for the efforts of all those who have worked for their release," Clinton said in a statement.

The men were arrested along the Iran-Iraq border in July 2009 and sentenced in August to eight years in prison. A third American in the group, Sarah Shourd, was freed last year on bail.

The release of the hostages one day before Iranian President Mahmoud Ahmadinejad is set to address the United Nations in New York has some analysts suggesting the decision was a political one.

"It put some pressure on the president and reminded him that he can't do anything he wants. They are doing everything in their power to limit his authority and show how powerless a president can be in Iran if he doesn’t have the Supreme Leader's support,” Camelia Entekhabifard, an Iranian blogger said, according to The Christian Science Monitor. “At the same time, Ahmadinejad will be attending the General Assembly meeting tomorrow, and they don't want him to be in New York empty-handed.”

Shafiei said the bail of $500,000 for each of the men was posted after some last-minute problems in the bank were resolved. He did not say what the source of the money was.

Last week, Oman dispatched a plane belonging to the Gulf country's ruler to fetch the two Americans if the freedom-for-bail was reached.

Omani officials, who maintain good relations with both Iran and the U.S., reportedly played a key role in negotiations with Iran and may have paid the $1 million bail. They only said the private plane, sent from Muscat to the Iranian capital last Wednesday, was still in Tehran.

Their families say they were just hiking in northern Iraq's scenic and relatively peaceful Kurdish region when they may have accidentally strayed over the unmarked border with Iran.

Since her release last year, Shourd has lived in Oakland, California. Bauer, a freelance journalist, grew up in Onamia, Minnesota, and Fattal, an environmental activist, is from suburban Philadelphia.

Bauer proposed marriage to Shourd while in prison.

The Associated Press contributed to this report.