Mandela is in "perilous" condition and on life support, according to an affidavit filed Friday and made public in the ruling Wednesday, according to a South African newspaper.
The judge's order means that grandson Mandla Mandela must reverse the action he took in 2011, when he moved the bodies from Mandela's hometown in Qunu to his birthplace of Mvezo, about 25 kilometers (15 miles) away. Mandla Mandela has authority in Mvezo as a tribal chief and has plans to create a Mandela shrine, hotel and soccer stadium there.
The case has sparked a wide discussion here about family relations and inheritance.
Mandela, who was imprisoned for 27 years, remained in critical condition in the hospital Wednesday. He was admitted June 8 with a lung infection.
South Africa's anti-apartheid hero said he wanted to be buried in Qunu and attended the burial of his son at the family plot there in 2005.
"It's an issue of greed, and everyone needs to be quite clear about that," said Charlene Smith, the author of three books on the former president, including "Mandela: In Celebration of a Great Life."
"Although he's been able to bring reconciliation to South Africa, he has this warring family," Smith said of Mandela. "He hasn't been able to bring peace at home."
The family divisions became public this week when 15 Mandela members, including wife Graca Machel, pressed a court case to order Mandla Mandela to return the bodies to Qunu. The judge ordered the bodies to be reburied Wednesday afternoon, and a hearse entered the Mvezo compound shortly after the verdict.
The Mail and Guardian newspaper obtained the affidavit that said Mandela's health is "perilous" and that a life support machine is helping him breathe.
The court filing said the family members want to bury Mandela in earth "in which his descendant's remains lie."
The affidavit filed by daughter Makaziwe Mandela shows the family believes Mandla Mandela is trying to force the burial of Mandela in Mvezo for financial gain.
Mandla Mandela said in a statement Wednesday that he is not against the repatriation of the bodies and will abide by the court decision. But his legal team contends that the graves cannot be exhumed until an appeal to rescind the order is heard.
The case pitted the Mandela family members against Mandla Mandela, who argued that as the family's eldest male he is entitled to move the graves. Upping the ante in the feud, a Mandela family member pressed criminal charges Tuesday against Mandla for tampering with a grave.
Mandela had six children — four daughters and two sons — with two wives. Only his three eldest daughters remain alive. Mandla Mandela is the first-born grandson.
The graves are that of Makgatho Mandela, who died in 2005 and is Mandla Mandela's father; Mandela's first daughter Makaziwe Mandela, who died as an infant in 1948; and Mandela's second son Madiba Thembekile Mandela, who died in a car accident in 1969.
Many in South Africa hope that by moving the children's graves back to the Mandela family plot in Qunu, Nelson Mandela will now get his wish for a burial at Qunu.
"The reason why they had to do this in a rush-rush is because they are definite now that he is going to die. So he does not have to die without his dying wish (burial in Qunu) having been fulfilled," said Mlawu Tyatyeka, an expert on the Xhosa culture of Mandela's family.
"By the time they will bury Mandela they want to have everything in place."
The case over the graves is only a part of a larger family battle over how to use the Mandela name and the millions of dollars in wealth Mandela will leave behind.
There is a "House of Mandela" wine label and two granddaughters are starring in a U.S. television reality show titled "Being Mandela." Some family members are also trying to oust several old allies of the former president from control of two companies. That dispute is headed for the courts.
Wednesday's case has captivated a nation that has received only periodic updates on Mandela's health over the last 26 days, since Mandela was admitted to a hospital early on a Saturday morning for a recurring lung infection.
The day after criminal charges were pressed against Mandla Mandela for tampering with a grave, one of South Africa's leading papers led with this dual-meaning headline: "Mandla in grave trouble."
Associated Press reporter Carley Petesch contributed to this report.
Copyright 2013 The Associated Press.