After 781 days in an Iranian prison, two American hikers jailed as spies were freed on a $1 million bail-for-freedom deal Wednesday.

Shane Bauer and Josh Fattal, both 29, left Tehran as darkness fell in the capital city and landed in the Gulf state of Oman, where their parents, siblings and former fellow inmate Sarah Shourd, of Oakland, greeted them at the airport. This closes an ordeal "that has taken a devastating toll on all of us," ending a high-profile international drama that drew efforts by President Barack Obama and pleas from boxing legend Muhammad Ali for their release.

Shourd, 33, was freed on $500,000 bail in September 2010 after more than a year in prison.

The two American men -- friends from their days at UC Berkeley -- were sentenced last month to eight years each in prison. They have maintained their innocence and denied the espionage charges against them.

The families waited on the tarmac at a royal airfield near the main international airport in Oman's capital, Muscat. About 20 minutes before midnight, Fattal and Bauer -- wearing jeans and casual shirts -- raced down the steps from the blue-and-white plane. They made no statements to reporters before walking into the airport terminal building, which was guarded by security officials. The men appeared thin but in good health.

"We're so happy we are free," Fattal told reporters in Oman. The two men made brief statements before leaving the airport with their families.

"Two years in prison is too long," Bauer said, adding he hoped their release will also bring "freedom for political prisoners in America and Iran."

Their families expressed happiness in a statement.

"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.

"We now all want nothing more than to wrap Shane and Josh in our arms, catch up on two lost years and make a new beginning, for them and for all of us."

Their release followed a week of mixed signals and political brinkmanship within Iran's leadership.

Over the 26 months, Iranian authorities often hinted at progress, only to then announce further delays, or worse, fall completely silent. Court dates were scheduled and canceled. All communication between the men and their families was cut off.

"The internal politics in Iran seem to have had a total chokehold on (Bauer and Fattal), and so today's news is such a welcome relief," said Sandy Close, executive director of New America Media in San Francisco, where Bauer worked as a freelance writer and photographer.

The hikers' families endured numerous dashed hopes -- calling the ordeal a "nightmare" that upended all their lives. Families had sleep and health problems, drained their bank accounts, closed businesses and devoted their lives to freeing their loved ones.

"This is taking a devastating toll on all of us," Josh Fattal's mother, Laura Fattal, said this year.

Wednesday's bail-for-freedom move was almost a mirror image of Iran's release of Shourd from Evin prison Sept. 14, 2010, and was seemingly timed while Iranian President Mahmoud Ahmadinejad prepared to visit New York for this week's United Nation's General Assembly session.

The Gulf state of Oman played a crucial role in the hikers' release. It has close relations with Tehran and Washington, D.C., and has acted as a mediator in the releases and the apparent transfer of the bail money because of U.S. economic sanctions on Iran.

The ordeal began after the three friends, who had worked and traveled in the Middle East, were hiking in northern Iraq's scenic and relatively peaceful Kurdish region, and may have accidentally strayed over the unmarked border with Iran, according to the U.S. government and their families.

Since their arrest in July 2009, Bauer, a freelance journalist from Minnesota, and Fattal, an environmental educator from suburban Philadelphia, had shared a small cell, which they left for 40 minutes a day, blindfolded and escorted by guards to an open-air room. Bauer proposed marriage to Shourd before her release.

Those who know the men called them "people-oriented, empathetic, steely and determined" and likely able to communicate with their captors and learn and understand some Farsi.

"But you can only imagine," said Ken Light, who taught Bauer at UC Berkeley's Graduate School of Journalism. "After (time) you begin to lose faith, and you're not getting information. I imagine he'll need some time to recover from the experience."

Both Obama and Sen. Barbara Boxer, D-Calif., called the release "wonderful news," but Boxer added that she "deeply regrets" that their release took so long. "Shane and Josh have been forced to pay too great a price by the Iranian government."

Staff writer Sean Maher and The Associated Press contributed to this report.