The appeal court has issued a damning judgment criticising the Home Office’s process in using a terrorism-related paragraph of immigration law as “legally flawed” and ruling it must be changed.

The Guardian has repeatedly highlighted the Home Office’s use of the rule – designed in part to tackle terrorism – to refuse applications from hundreds of people for making legal amendments to their tax records.

The department has tried to force at least 300 highly skilled migrants to leave the UK under paragraph 322(5), with a further 87 having left and another 400 potentially affected, between January 2015 and May 2018.

The court of appeal has examined four of these cases in depth. The immediate result of its 60-page judgment is that one of these cases has been quashed while the other three will be allowed to appeal, including one in which the court said there was “at least arguably, a distinct unlawfulness, in that the secretary of state failed to make an explicit finding of dishonesty”.

But the wider impact of the judgment is the court’s finding that the “general approach [by the home secretary, Sajid Javid] in all earnings discrepancy cases [has been] legally flawed” and must change. Criticism of the Home Office’s use of the clause has become part of the wider debate over the “hostile environment” and a target-based culture that also gave rise to the Windrush scandal.

In the judgment delivered on Tuesday morning by Lord Justice Underhill, Lord Justice Hickinbottom and Lord Justice Singh, Javid was criticised for assuming the applicants’ amendments to their tax records were “the result of dishonesty, without giving applicants an opportunity to proffer an innocent explanation”.

Javid was at further fault, the judgment went on, for failing to “address the further questions of whether the dishonesty in question render[ed] the presence of the applicant in the UK undesirable or whether there are other factors which outweigh the presumption in favour of removal, or give applicants the opportunity to raise any matters relevant to those questions”. This question, the judges said, “cannot simply be ignored”.

The court also gave applicants threatened under 322(5) a new and extra layer of protection by finding that all further use of the clause must be subject to article 8 of the European convention on human rights, meaning the notice of liability to removal – which is the consequence of refusal of indefinite leave to remain – will “constitute an interference with those rights which the secretary of state will have to justify”.

The judgment added: “His decision on that question will be reviewable as a matter of fact, whether in the context of a ‘human rights appeal’ or, where no such appeal is available, in judicial review proceedings.”

There are more than 70 other 322(5) appeals or applications for permission to appeal pending before the court and an unknown number of challenges pending in the first-tier tribunal or upper tribunal. “The intention is that our decision in these appeals will determine the various issues of principle raised in at least most of the pending legal challenges in all of these cases,” the court said.

The lack of opportunity for applicants to appeal a finding of guilt under 322(5) was also criticised as unlawful by the court: in administrative review, the applicant is not normally allowed to produce new evidence to counter accusations of dishonesty.

A Home Office spokesperson said: “The court agreed that the use of paragraph 322(5) is appropriate in these types of cases and that we are right to expect a full and convincing explanation from people when there are discrepancies in their tax records and immigration applications. We will consider the judgment and our response carefully.”

Many of those affected had lived in the UK for a decade or more and have British-born children. Some were given 14 days to lodge an appeal and were no longer eligible for a visa to visit the UK or any other country. Those who appeal face severe restrictions on their right to work, have a bank account, hold a driving licence or access free NHS treatment while they do so.

The cases were those of Ashish Balajigari, represented by Michael Biggs, Amor Albert, represented by Parminder Saini, and Somnath Mujumder and his wife, who were represented by Shahadoth Karim, all from 12 Old Square chambers. Avais Kwos and his family – who have already left the country after being refused under 322(5) – were represented by Alexis Slatter of Goldsmith Chambers.

Saini said: “This is a not insignificant defeat on a controversial, much-publicised issue at the heart of the hostile environment.

“The judgment in short confirms that the government’s allegations against migrants in relation to their tax returns amounts to an allegation of deliberate misrepresentation to either the Home Office or HMRC.

“The court states that a large number of migrants have claimed that in their cases, errors which were the result only of carelessness or ignorance have wrongly been treated as dishonest, and that the Home Office has been too ready to find dishonesty without an adequate evidential basis or a fair procedure.

“In the case of Albert, which I represented, the court accepted that the Home Office had failed to even allege he was dishonest in his tax affairs.”

The Scottish National party MP Alison Thewliss said the decision “underlines what victims and campaigners have been telling the UK government all along; that its application of the immigration rules for highly skilled migrants is not fit for purpose.”

She added: “The court has been unequivocal in its denunciation of the Home Office. They call their approach “legally flawed”, and criticise the department’s decision – in all earnings discrepancy cases of this type – to proceed directly from finding that any discrepancy occurred to deciding that applicants had been dishonest, without even considering evidence to the contrary. This is patently unfair.

“It’s been clear for some time now that the Home Office made a calculated decision, without forethought for the impact on applicants, to pursue people via this immoral and disreputable application of immigration rules … The Home Office should do the respectable thing and withdraw its objections immediately”.

• This article was amended on 19 April 2019. An earlier version said that some people were given just 14 days to leave. That should have said “14 days to lodge an appeal”. It was further amended on 24 April 2019 to correct a misspelling of the first name of Amor Albert as Amin.