1 of 9
Osama Faisal, AP
American couple Grace, right, and Matthew Huang walk to their gate with U.S. Ambassador to Qatar, Dana Shell Smith, center, at the Hamad International Airport in Doha, Qatar, Sunday, Nov. 30, 2014. A Qatari appeals court on Sunday overturned a ruling against an American couple over the death of their adopted daughter and said they are free to leave, ending a closely watched legal saga that may have stemmed from cultural misunderstandings in the conservative Gulf nation. (AP Photo/Osama Faisal)

DOHA, Qatar — A U.S. couple in Qatar who spent nearly two years fighting accusations they had killed their adopted daughter from Ghana were acquitted of wrongdoing Sunday in an emotional courtroom reversal by an appellate judge who said they were good parents and the prosecution had no case.

But the joy and relief expressed by the couple, Matthew and Grace Huang of Los Angeles, gave way hours later to new frustrations and fear, as Qatari immigration officials prevented them from leaving the country even though the appellate judge had said they were free to go home.

Tensions at Doha’s international airport escalated as the Huangs, escorted by legal representatives and the U.S. ambassador, Dana Shell Smith, were told a travel ban on the couple was still in effect. It was unclear why.

Smith and other U.S. diplomatic officials went into private talks with the Qataris, but by Sunday evening there was no resolution.

In what appeared to be a significant intervention in the standoff, Secretary of State John Kerry got involved, issuing a statement welcoming the appellate court decision and expressing concern about the unexpected holdup. Kerry said he had spoken to Qatar’s foreign minister, Khalid bin Mohammed al-Attiyah, about the Huangs, and had “called on the government to immediately implement the court’s decision and permit their return to the United States without further delay.”

The Huang case has attracted widespread attention because of the flimsiness of the evidence, its racial overtones, and the prosecution’s insistence on pressing forward. The case has become a public relations problem for Qatar, the aspiring affluent Gulf emirate and increasingly important U.S. ally, home to the largest U.S. military air base in the Middle East.

On Monday, the Huangs issued a statement through their legal representatives expressing their deep exasperation at the prospect of spending more time in Qatar.

“We just left the airport after waiting all day for the U.S. government to get us out of Qatar,” they said. Despite their appeals for more robust American pressure, they said, “Our requests are being ignored, and we are beyond frustrated.”

People connected to the case said they believed the delay may have been caused more by Qatar bureaucracy and not a new effort to re-prosecute the Huangs. U.S. and Qatari officials in Doha declined to comment.

The couple’s disappointment punctuated the end of a roller-coaster day that began in the appellate courtroom, where the Huangs sobbed and hugged friends and family as the judge said they were free to go and that the prosecution’s case against them was fatally flawed.

The Huangs immediately departed the courtroom with their legal representatives and sought to make arrangements to leave Qatar and fly home to reunite with their two other children, both adopted boys, from Ghana and Uganda.

“This has been an emotional trial for me and my family,” Matthew Huang said in a statement he read outside the courtroom. “Grace and I want to go home and be reunited with our sons. We have been unable to grieve our daughter’s death. But we want to thank the judge for today’s decision.”

Asked outside the court what she was looking forward to the most, Grace Huang said, “Seeing our kids, seeing our sons.”

The parents spent nearly a year in prison before their case was heard for the first time last November, when they were released on their own recognizance but ordered to remain in Qatar. Their other two children already had been sent home to the United States in the custody of Grace Huang’s mother.

In March, the couple was found guilty of a reduced charge, child endangerment, and sentenced to three years in prison. They appealed to have the verdict dismissed, while prosecutors sought a more severe sentence. The Huangs were ordered to remain in Qatar pending the appeals court decision.

On Sunday, the appellate judge, Abdul Rahman al-Sharafi, discredited the prosecution’s case point by point in his ruling, a highly unusual development in the Qatari judicial system, in which prosecutors and the police are often heavily favored.

Al-Sharafi said that it was clear that the Huangs were good parents who cared for their children, as shown by witness testimony, and that their two other children were not abused. He also questioned, as the Huangs’ defense lawyers had done, the integrity of the forensic report that was the crux of the prosecution’s case.

“The defense offered plenty of proof that they are not guilty,” he said.

Matthew Huang, reached later by telephone, said it was the first time in the case that a judge had acknowledged all the reasons the prosecution’s case was groundless.

“We were very excited by the decision today,” Huang said. “We are glad the truth came out.”

The case took on added significance as the State Department repeatedly expressed its concern about the fairness of the prosecution, which originally charged the Huangs with murder in the death of their 8-year-old daughter, Gloria, in January 2013, and had suggested that the Huangs were child traffickers.

The prosecution had argued that the Huangs had killed Gloria by denying her food. The Huangs said she had an eating disorder, a vestige of her impoverished upbringing in Africa. A precise cause of death was never established.

(STORY CAN END HERE. OPTIONAL MATERIAL FOLLOWS.)

The case laid bare some ingrained prejudices in Qatar about adoption and multiracial families. Part of the original prosecution argument rested on suspicion that the Huangs, who are of Asian descent, could not have possibly adopted a black African girl and must have been seeking to sell her or her organs.

The Huangs had moved to Qatar in July 2012 with their children because Matthew Huang had been hired as a public works engineer in Doha as part of its preparations for the 2022 World Cup tournament.

There was no immediate comment on the Huangs’ acquittal from Huang’s former employer, MWH Global, a leading international public works engineering firm based in Broomfield, Colorado.