Supreme court justices have unanimously backed Theresa May’s “particularly harsh” £18,600 minimum income rule for British citizens to bring non-European spouses into Britain that campaigners say has led to tens of thousands of families being separated.

But the supreme court ruling does acknowledge that the rule has caused hardship for thousands, and criticises the lack of focus on the treatment of children and the ability of Home Office staff to consider alternative assets when they assess the earning ability of the British spouse.

Lord Carnwath said he and his fellow judges had held “that the minimum income threshold is accepted in principle” but he added that the Home Office’s rules and instructions failed to take full account of their legal duties in respect to the children involved or to allow alternative sources of funding to be considered.

The justices ruled that current Home Office rules and guidance are defective and unlawful until they are amended to give more weight to the interests of the children involved. This could give limited hope to some of the separated families with children but the four families who brought the appeal will not find out whether they can live together in Britain until their cases are reconsidered.

The £18,600 minimum income threshold for British citizens to bring non-European Economic Area spouses to live with them in the UK was introduced by May when she was home secretary in 2012 as part of her drive to reduce net migration below 100,000 and the ruling will come as a major relief to the Home Office.

It was estimated in 2015 that the £18,600 threshold excludes 41% of the British working population, including 55% of women, from bringing a foreign spouse to live in Britain. The threshold rises to £22,400 if there is one or more non-European-born child in the family. The income of the non-European partner does not count towards the threshold.

The ruling testing the legality of the family visa rules covered several linked cases. Two of them, Abdul Majid and Shabana Javed, involve British nationals married to Pakistanis; a third, known as MM, is a Lebanese refugee. A nephew of MM, known as AF, is also an appellant, as well as SS, a refugee from the Democratic Republic of the Congo.

The ruling is a blow to campaigners who say the rule has meant British families have faced a choice of separation or living in exile. They have highlighted the plight of up to 15,000 British children who have grown up as “Skype kids” to keep in contact with one of their parents since the rule was introduced.

The supreme court justices acknowledge in their judgment that the £18,600 rule “causes hardship to many thousands of couples, including some who are in no way to blame for the situation in which they find themselves” but add that “does not mean that it is incompatible” with article 8 of the European convention on human rights on the right to family life.

The supreme court also agreed that the income rule has “a particularly harsh effect” on British citizens who have lived and worked abroad, have married or formed stable relationships there and now cannot return home to Britain.

It is also particularly harsh for couples who got together before 2012. “Of particular concern is the impact upon the children of these couples, many or even most of whom will be British citizens themselves,” they add.

The justices also acknowledge that the rule “does present a serious obstacle to their enjoying family life together” and may provide a permanent obstacle to many couples because those earning less than £18,600 are unlikely to amass sufficient savings to make good the shortfall. Women and especially those from minority ethnic groups will be particularly hit because of the gender pay gap.

But they have ruled that the £18,600 threshold is a legitimate part “of an overall strategy aimed at reducing net migration. Its particular aims are no doubt entirely legitimate to ensure, as far as practicable, that the couple do not have recourse to welfare benefits and have sufficient resources to be able to play a full part of British life.” They say that, given that is a legitimate aim, it was not possible to say that “a less intrusive measure” should have been adopted.

Immigration welfare campaigners took comfort in the supreme court’s findings that the rule was causing hardship to thousands of families and that the interests of children needed to be reconsidered.

Saira Grant, the chief executive of the Joint Council for the Welfare of Immigrants, said: “This judgment is a real victory for families, especially those with children. For five years JCWI has been working with affected families and has been trying to persuade the government to abandon the family migration rules it introduced in 2012 because they are tearing families apart and significantly harming children.

“The supreme court has now declared this to be the case. These rules are unlawful as they do not safeguard the best interests of children. The strict requirement that only the sponsor’s personal finances can allow the £18,600 threshold to be met has also been discredited.”

She added: “The supreme court has said that alternative funding sources should be taken into account when a person’s right to family life could be breached. These are significant victories for families up and down the country. This judgment confirms that the government’s position is now untenable and they must now take immediate steps to protect the welfare of children in accordance with their legal duty.”

A Home Office spokesperson said the court had endorsed its approach in setting an income threshold for family migration that prevents a burden on the taxpayer and ensures migrant families can integrate into our communities.

“This is central to building an immigration system that works in the national interest,” they said.

“The current rules remain in force but we are carefully considering what the court has said in relation to exceptional cases where the income threshold has not been met, particularly where the case involves a child,” they added.