The government is being warned that it will face judicial review proceedings in June unless it scraps a clause in the data protection bill that would prevent immigrants from accessing their Home Office records.

The campaign groups the3million, a grassroots organisation representing EU citizens living in the UK, and the Open Rights Group argue that the exemption for data protection for immigrants is unlawful and will make EU citizens and others “second-class citizens” without full access to government files.

Rosa Curling, a human rights lawyer at Leigh Day, which has been hired by the groups, said the exemption is of major concern given that EU citizens will soon have to register for “settled status” in Britain after Brexit. If they are denied this, they will find it difficult to appeal without access to their Home Office records, she said.

“If the exemption is made law, our clients will apply for judicial review. They have spent months trying to persuade the government to remove the exemption from the bill,” Curling said. “If they continue to refuse to listen, our clients will have no option but to seek the court’s intervention in this matter on an urgent basis.”

Leigh Day is planning to write to the government this week to warn of legal action by the campaign groups if Theresa May does not remove the exemption at the third reading of the bill in the House of Commons on Wednesday.

The 2018 Data Protection Act is due to become law on 25 May and was designed to implement General Data Protection Regulation rules, bringing data protection up to date across the EU.

But the proposed legislation says GDPR provisions will not apply “to personal data process for any of the following purposes: the maintenance of effective immigration control or the investigation or detection of activities that would undermine the maintenance of effective immigration control”.

Curling said the exemption was “counter to the goal” of GDPR and will have implications for all citizens who come into contact with immigration procedures.

“This affects anyone coming into contact with the immigration process, not just immigrants. It exempts controllers processing any personal data for the unclear and undefined concept of ‘effective immigration control’, so immigrants and citizens alike,” she said.

Because of the general nature of the exemption, it could prevent people from accessing data from all public organisations caught up in Home Office decisions, including HMRC, the police and private contractors such as G4S.

The campaign groups say the Windrush scandal underlines how casually lives can be harmed by Home Office mistakes and, if the data protection bill becomes law, EU citizens could be left in a similar position.

Gudrun Parasie, a lawyer with the3million, said: “The Windrush case has proved yet again that the Home Office prefers to hide their mistakes.

“This is a complete breakdown of access to justice. Someone could press the wrong button and you could be accused of fraud or something, and you would never know.”