Chief Justice Lovemore Munlo, reading the three-judge panel's ruling, also said the singer's commitment to helping disadvantaged children should have been taken into account when deciding on Madonna's request to adopt 3-year-old Chifundo "Mercy" James.
Madonna has founded a charity, Raising Malawi, which helps feed, educate and provide medical care for some of Malawi's more than 1 million orphans, half of whom have lost a parent to AIDS.
Children's welfare groups had expressed concern that rules meant to protect children were being bent because of Madonna's celebrity, and perhaps out of gratitude for what she has done for Malawi, one of the world's poorest and most AIDS-ravaged countries.
Madonna's lawyer Alan Chinula said he called his client after the ruling.
"It's the wee hours of morning in New York but she is excited at the news," Chinula said. "As her lawyer I am happy that this has settled this contentious issue."
Chinula said he would now turn to arranging a passport for Chifundo, which could take several days, and was awaiting word from Madonna on travel plans for the girl. The adoption may not be final for some time.
Madonna had appealed after the lower court ruled she could not adopt the girl because the singer had not spent enough time in Malawi. The lower court said residency rules had been bent when Madonna adopted her son David from Malawi last year.
The appeals court said that was a narrow interpretation based on old laws.
"In this global village a man can have more than one place at which he resides," Munlo said in the ruling, which took more than an hour to read in court Friday. "The matter of residence should be determined at the time of application of the adoption. In this case, Madonna was in Malawi not by chance but by intention. She is looking after several orphans whose welfare depends on her. She can therefore not be described as a sojourner."
The ruling also said the judges saw only two options for Chifundo, "either to stay at the orphanage without the love of family and live with the possibility of destitution or be with Madonna where she is assured of love.
"Every child has the right to love."