Circuit Judge Rodney J. Steele last month granted temporary custody to the woman's father and his wife. But on Monday he said Sally Barakat has a constitutional right to raise the boy as she sees fit.
Some Muslim groups had said the judge's earlier decision was driven by anti-Islamic bias.
"I'm thankful to have good news," Barakat, 29, said Monday. "I thank God and I thank the judge."
Custody was conditioned on Barakat not taking 5-year-old Trevor Rederth out of South Dakota until visitation rules can be set up with Conrad and Julie Rederth.
Barakat has said her father and his spouse denigrated her religion and made racist comments about her husband, Osama Barakat, whom she met over the Internet. Testifying Monday, Conrad Rederth said he doesn't care about Barakat's religion, but objects to her taking Trevor to Egypt, where he said Americans are despised and the boy would be "a third-class citizen."
The Rederths' attorney, Karen Crew, presented a State Department document advising Americans to be careful while traveling in the Middle East and North Africa. "The U.S. government says that terrorists are looking for what they refer to as 'soft targets,"' Crew said.
But Barakat's attorney, Tom Keller, argued the document was merely a general warning for the region. Americans are free to travel to Egypt, which is politically stable, he said.
Ibrahim Hooper, spokesman for the Washington-based Council on American-Islamic Relations, said the judge's decision showed Muslims could still have faith in the U.S. legal system. "That's being tested right now because the Muslim community feels under siege," Hooper said.
The Rederths said outside court they have not decided whether to appeal. "I think the justice system failed a little boy," Conrad Rederth said as his wife stood beside him in tears.