The families called this "the best day of our lives," and President Barack Obama said their release - under a $1 million bail-for-freedom deal - "wonderful news."
The release capped complicated diplomatic maneuvers over a week of confusing signals by Iran's leadership on the fate of Elkins Park native Josh Fattal and Shane Bauer.
Although the fate of the two gripped America, it was on the periphery of the larger showdowns between Washington and Tehran that include Iran's nuclear program and its ambitions to widen military and political influence in the Middle East and beyond. But - for a moment at least - U.S. officials may be adding words of thanks in addition to their calls for alarm over Iran.
For Tehran, it was a chance to court some goodwill after sending a message of defiance with hard-line justice in the July 2009 arrests of the Americans along the Iran-Iraq border. The Americans always maintained they were innocent hikers.
"Today can only be described as the best day of our lives," said a statement from their families. "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," the statement added.
Obama called it "wonderful, wonderful news about the hikers, we are thrilled ... It's a wonderful day for them and for us."
The families waited on the tarmac at a royal airfield near the main international airport in Oman's capital, Muscat. Also returning to Oman was Sarah Shourd, who was arrested with Bauer and Fattal but freed a year ago. She received a marriage proposal from Bauer while in prison.
At 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, and hoped their release from prison will also bring "freedom for political prisoners in America and Iran."
In many ways, the release was a mirror image of the scene last year when Shourd was freed on $500,000 bail. That deal, too, was mediated by Oman, an Arabian peninsula sultanate with close ties to both Tehran and Washington. A statement from Oman said it hoped the release would lead to better ties between Iran and the U.S.
The gray metal gates of Tehran's Evin prison finally opened for Shourd - as it did for her companions on Wednesday - as Iranian President Mahmoud Ahmadinejad was preparing for the spotlight in New York at the U.N.'s annual gathering of world leaders last year. He is scheduled to address the world body again Thursday.
Just a month ago, Bauer and Fattal - both 29 - were appealing their eight-year prison terms for espionage and illegal entry into Iran. They denied the charges and said they were merely hikers in Iraq's relatively peaceful Kurdistan region who wandered close to Iran's border.
The first hint of change came last week when Ahmadinejad said they could be released within days.
But then came the voice of the hard-line ruling clerics, who have waged a stinging campaign against the president and his allies in recent months as part of power struggle.
The clerics made it clear: Only they have the authority to set the timing and ground rules to release the men. After several days of halting progress, their defense attorney secured the necessary judicial approval for the bail on Wednesday.
"I have finished the job that I had to do as their lawyer," said their defense attorney Masoud Shafiei. He obtained signatures of two judges on a bail-for-freedom deal. A $1 million bail - $500,000 for each one - was posted.
Hours later, the men were in a convoy with Swiss and Omani diplomats headed to Tehran's aging Mehrabad airport - whose designers in the 1950s included the late American architect William Pereira. One of the last Tehran landmarks on the convoy's route was the massive Azadi Square, which is used for military parades but also was a temporary hub for protesters after Ahmadinejad's disputed re-election in 2009.
Oman - ruled by a lute-playing sultan - has acted as mediator in the releases and the apparent transfer point for the bail money because of U.S. economic sanctions on Iran. Oman also plays a strategic role in the region by sharing control with Iran of the Strait of Hormuz at the mouth of the Gulf, which is the route for 40 percent of the world's oil tanker traffic.
Switzerland represents U.S. diplomatic interests in Iran because the U.S. broke off diplomatic relations with Tehran shortly after the 1979 Islamic Revolution. Iraq also sent envoys to neighboring Iran during the negotiations over the release.
In one possible parting shot by Iran, the release came just minutes before Obama addressed the U.N. General Assembly. There was no direct evidence that Iran timed the American's freedom to overshadow Obama's speech, but Iran has conducted international political stagecraft in the past.
Most famously, Iran waited until just moments after Ronald Reagan's presidential inauguration in January 1981 to free 52 American hostages held for 444 days at the former U.S. Embassy after it was stormed by militants backing Iran's Islamic Revolution. The timing was seen as a way to embarrass ex-President Jimmy Carter for his backing of Iran's former monarch. Though the release eases one point of tension between Iran and the U.S., major conflicts still persist.
Washington and European allies worry Iran is using its civilian nuclear program as cover to develop atomic weapons and have urged for even stronger sanctions to pressure Tehran. Iran denies any efforts to make nuclear weapons. Iran, in turn, is deeply concerned about the U.S. military on its borders in Iraq and Afghanistan, and sharply denounces U.S. influence in the Middle East.
The London-based rights group Amnesty International called the release of the Americans a "long overdue step."
"Iranian authorities have finally seen sense" and have agreed to release Bauer and Fattal, said Hassiba Hadj Sahraoui, Amnesty International Deputy Director for Middle East and North Africa.
The last previous direct contact family members had with Bauer and Fattal was in May 2010, when their mothers were permitted a short visit in Tehran. Iranian officials also used the reunion for high-profile propaganda: Using extensive clips on its international English-language TV and its web site.
In recent days, Iran has used the men's pending release to draw attention to Iranians in U.S. prisons and difficulties faced by their families such as securing visas for visits.
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.
Shourd and Bauer had been living together in Damascus, Syria, where Bauer was working as a freelance journalist and Shourd as an English teacher. Fattal, an environmental activist, went to visit them in July 2009 shortly before their trip to northern Iraq.
Their case of the three Americans closely parallels that of freelance journalist Roxana Saberi, an Iranian-American who convicted of spying before being released in May 2009. Saberi was sentenced to eight years in prison, but an appeals court reduced that to a two-year suspended sentence and let her return to the U.S.
In May 2009, a French academic, Clotilde Reiss, also was freed after her 10-year sentence on espionage-related charges was commuted.
Last year, Iran freed an Iranian-American businessman, Reza Taghavi, who was held for 29 months for alleged links to a bombing in the southern city of Shiraz, which killed 14 people. Taghavi denied any role in the attack.
Murphy reported from Dubai, United Arab Emirates. Associated Press reporter writer Surk contributed from Dubai.
Find out about Breaking News as it happens. Sign up for 6abc.com Breaking News Alerts.