A Union Jack flag flutters next to European Union flags ahead of a visit of Britain's Prime Minister Theresa May and Britain's Secretary of State for Exiting the European Union David Davis at the European Commission headquarters in Brussels, Belgium October 16, 2017. REUTERS/Francois Lenoir

LONDON (Reuters) - The British government said on Tuesday that most European Union citizens currently living in Britain will be allowed to remain in the country after Brexit in 2019.

Outlining plans for a mass registration program, the Department for Exiting the European Union and the interior ministry said EU nationals will be given a two-year grace period to apply for settled status after Britain leaves the EU.

The legal status and rights of EU nationals is one of the thornier issues in Britain’s complicated exit from the bloc.

There are about 3 million EU citizens living in Britain.

Caseworkers will be able to use discretion when processing applications, meaning they should not be refused for minor technicalities, and the majority would be granted, the departments said in a statement.

The cost of an application should be no more than the cost of a British passport and EU citizens will also be given a statutory right of appeal if denied.

“We have been clear that safeguarding the rights of EU citizens is our top priority in negotiations,” Brexit minister David Davis said. “We will support everyone wishing to stay to gain settled status through a new straightforward, streamlined system.”