(CNN) -- A judge who barred Madonna's second adoption from Malawi on Friday said she had "a gripping temptation" to approve the adoption, but decided doing so would open doors to child trafficking, court records show.
A judge rejected Madonna's adoption application on Friday.
The American pop star had filed a petition to adopt a girl, Chifundo James, 3. The rejection was based on a residency requirement and the judge's belief that the child was in good hands at an orphanage.
"There is a gripping temptation to throw caution to the wind and grant an adoption in the hope that there will be a difference in the life of even just one child," Justice E.J. Chombo wrote in a ruling.
"But removing the very safeguard that is supposed to protect our children ... could actually facilitate trafficking of children by some unscrupulous individuals." Watch why court refused adoption bid »
Chombo was referring to a residency requirement in Malawi law that requires people to live in the country for some time before adopting.
If Madonna was granted the adoption without established residency, critics argue it could open the door for others to adopt children and leave the country.
"Anyone could come to Malawi and quickly arrange for an adoption that might have grave consequences on the very children that the law seeks to protect," the judge wrote.
Court papers provided to CNN also revealed that the judge considered the petition different from that of David Banda, whom Madonna adopted from Malawi in 2006.
David "was to be returned to his biological father within a period of six months from the time that Mchinji Orphanage had admitted him," Chombo wrote.
"This is the same father that had desperately appealed for help after the death of his wife because of his incapacity to look after David and the unwillingness of wife's family to care for the child."
In the case of Chifundo, the orphanage taking care of her was able and willing, according to Chombo, who did not handle the first adoption. Court records show her 14-year-old mother died days after her birth.
The ruling followed weeks of criticism by human rights activists, who accused the mother of three of using her fame to circumvent a residency law for foreigners adopting in the country.
Save the Children UK had also urged Madonna to let the child be raised by her relatives in her home community.
The denial was applauded by a coalition of local nonprofits.
"Inter-country adoption is not the best way of providing protection to children ... supporting children from outside our country only helps five of the 1.5 million orphans we have," said Mavuto Bamusi, the national coordinator of Malawi Human Rights Consultative Committee.
Malawi government officials said Thursday that they supported Madonna's second adoption.
The recently divorced singer was married to British filmmaker Guy Ritchie. She has been involved with Malawi for several years and made a documentary, "I Am Because We Are," to highlight poverty, AIDS and other diseases devastating children in that country. She also co-founded a nonprofit group, Raising Malawi, which provides programs to help the needy.
Madonna's lawyer has filed a notice to appeal the ruling with the Supreme Court, according to Ken Manda, high court registrar.
CNN's Faith Karimi contributed to this report