His two-year battle ended yesterday when a High Court judge was told that a London council's social services department had at last agreed to his request.
The 15-year-old "H", who cannot be named for legal reasons, had launched a legal challenge against Wandsworth Borough Council.
He accused the authority of "unreasonably and irrationally" refusing to give due consideration to his wish to live with gay foster carers. He had repeatedly made the request to the council.
His application for judicial review was withdrawn yesterday before Mr Justice Cazalet after the council indicated it would now comply with his request.
"H" was first accommodated by Wandsworth in February 1996, following family problems. From the start, he asked for gay foster carers. "H", whose ambition is to become a performing artist, hugged his team outside court and said yesterday: "I am really happy. Two-and-a-half years of torment are finally over.
"I can start living my childhood, which has been ripped away from me over the last two-and-a-half years."
He thanked his legal team, led by the barrister Alan Inglis and solicitor Paul Aitchison, and his mother, for being "completely supportive all the way through".
His solicitor, Paul Aitchison, said outside court that he was "astounded" by the refusal of Wandsworth social services to agree to the 15-year-old's request. He said all the social workers involved had recommended that he should be placed with gay carers.
Mr Aitchison said: "We are not saying that H's sexuality was the only issue, as clearly that was not the case.
"Wandsworth adopted a political stance, rather than a child-centred stance."