WASHINGTON — A divided Supreme Court ruled Monday that immigrant children who waited for years with their parents to obtain visas still have to go to the back of the line when they turn 21.

In a 5-4 decision, the justices sided with the Obama administration in finding that immigration laws offer relief only to a tiny percentage of children who "age out" of the system. The majority no longer qualify for the immigration status granted to minors.

The case involved Rosalina Cuellar de Osorio, a Salvadoran immigrant who was in line for a visa along with her 13-year-old son. But after years of waiting, her son turned 21 and government officials said he no longer qualified as an eligible child. He was placed at the back of the line, resulting in a wait of several more years.