A government decision to charge £1,012 to register children as UK citizens was "unlawful", the High Court has ruled.
The fee applies to children born outside the UK, and those born in the UK before their parents were granted citizenship or settled status.
Delivering the ruling judge Mr Justice Jay said the Home Office "failed to have regard to the best interests" of children affected.
The department said it will consider the ruling's implications "carefully."
Young people currently face a £1,012 registration fee before they can formally become British citizens - despite applications costing the Home Office £372 to process.
Fees have risen since 2011, and the cost of registering two children has more than tripled due to fee increases and the abolition of second child discounts.
The last increase resulted in the charge increasing from £973 to the current £1,012 fee in April 2018.
Campaigners accused the government of "shamelessly profiteering" and said the "landmark ruling" could help tens of thousands of children growing up in the UK gain citizenship.
Mr Justice Jay said the evidence during the hearing had shown that "for a substantial number of children, a fee of £1,012 is simply unaffordable".
He said this made the children affected "feel alienated, excluded, isolated, second-best, insecure and not fully assimilated into the culture and social fabric of the UK".
The case was brought on behalf of two children by campaign group the Project for the Registration of Children as British Citizens (PRCBC).
Both children - identified only as O, aged 12, and A, aged three - were born in the UK and have lived there their entire lives.
During the hearing, O told the court that she feared her school friends would find out that she is "not British like them".
Mr Justice Jay that O and her mother could only afford the fee "by taking steps which to my mind would be wholly unreasonable".
'As British as my friends'
And he said there was "no evidence" that the Home Office had "identified where the best interests of children seeking registration lie, has begun to characterise those interests properly (or) has identified that the level of fee creates practical difficulties for many".
Responding to the judgment, O said she felt "as British as any of my friends".
"I want to be able to do all the things my friends can," she said. "I don't want to have to worry they will find out I don't have a British passport and think that means I am not the same as them."
The PRCBC had also argued that the £1,012 fee effectively removes children's entitlement to citizenship.
However, Mr Justice Jay dismissed this and said that he was referring the issue "to be considered in the Supreme Court if that court so advises".
The judge also gave the Home Office permission to appeal against his ruling.
In a statement after the ruling, Solange Valdez-Symonds, co-founder of the PRCBC, called on the government to scrap the fee immediately.
"It is significant that the court has recognised British citizenship is the right of these and thousands of children and that the consequences of blocking their registration rights is alienating and harmful," she said.
"While that recognition is a great step forward, the fact remains that tens of thousands of British children are growing up in this country deprived of their rights to its citizenship, including by this shamelessly profiteering fee."
A Home Office spokesman said: "We note the court's judgment and will consider its implications carefully."