Despite strong Home Office opposition, five law lords unanimously decided that the needs of the girl, now aged nearly 18, outweighed the need to maintain "an effective and consistent immigration policy".
The judgment is likely to make it easier for UK citizens to adopt children from abroad if it can be shown the move "safeguards and promotes the welfare of the child" throughout childhood, and the child's wishes and feelings have been properly taken into account.
"B", who cannot be named, left a background of poverty in Jamaica to stay with her grandparents, both UK citizens, in 1995 when aged 14.She attended a school in Leeds.
In a written judgment, Lord Hoffmann, sitting with Lords Nicholls, Hope, Hutton and Millett, described how the girl's grandparents, who had emigrated to Britain nearly 40 years ago, decided to adopt B, with her mother's consent, to give her a better start in life.
Allowing an appeal against a Court of Appeal ruling which prevented an adoption order, Lord Hoffmann said: "In cases in which it appears to the judge that adoption would confer real benefits upon the child during its childhood, it is very unlikely that general considerations of 'maintaining an effective and consistent immigration policy' could justify the refusal of an order. The two kinds of consideration are hardly commensurable so as to be capable of being weighed in the balance against each other."
Lord Hoffmann described how B had done well at school and had "good prospects of taking A-levels and going to a university".
But the Home Office had ordered B to return to Jamaica, where her father had died and her mother, elder sister and four children lived "in a primitive concrete house" without a toilet or electricity. "They had very little money and were often hungry".
In October 1997, a High Court Family Division judge ruled in favour of adoption and said the welfare benefits to B "were so strong that immigration policy was insufficient to override them", said Lord Hoffmann. The Court of Appeal disagreed and said that the High Court judge, Mr Justice Sumner, had failed to distinguish the advantages of adoption itself from those of B acquiring a right to live in the UK. Apart from the advantages which flowed from the right of abode, adoption would have no advantages to the child, said the appeal judges.
But yesterday Lord Hoffmann, with the four other law lords also agreeing, said the appeal judges had ignored "the considerable benefits" from adoption which B would have accrued during the remainder of her childhood.
Lord Hoffmann said: "No doubt the views of the Home Office on immigration policy were also a circumstance which the court was entitled to take into account, although it is not easy to see what weight they could be given."Reuse content