An inquiry must be held as “a matter of urgency” after EU citizens living in the UK were denied the chance to vote in the European Parliament election, according to Mike Russell.

Thousands complained on social media under the hashtag #Deniedmyvote, citing apparent administrative errors by local councils, when they tried to cast their vote on Thursday.

In a letter sent to Cabinet Office Minister David Lidington and the Electoral Commission, the Scottish Government’s Constitutional Relations Secretary said it was an  “outrageous deprivation of democratic rights”.

He wrote: “It is a disgrace that in addition to the uncertainties that EU citizens have had to endure over the last almost three years since the EU referendum, some have been denied their right to vote in the European Parliament election.

“We want EU citizens in Scotland to feel settled and secure, and to continue to feel welcome and valued in Scotland.

“This debacle will do nothing to ease their concerns.

“We also have first-hand reports of EU citizens being unable to vote even though they had completed and returned the forms on time.”

Mr Russell added any seat secured by a small margin could be impacted by the incident.

“I would ask you to investigate the scale of this problem, which may have arisen due to the lack of time in the run-up to the election,” he wrote.

“I believe it is imperative that an inquiry is conducted into these issues as a matter of urgency.

“Any seat that is secured by only a small number of votes could be impacted by this outrageous deprivation of democratic rights.”

The Electoral Commission said it can “understand the frustration” caused by the situation and attributed the problem to the “very short notice” on the UK’s participation in the European election.

EU citizens must transfer their vote from their member state to the UK in a process that must be done 12 working days in advance of the poll, a process the Electoral Commission said “could be made easier”.

It said in a statement issued on Thursday: “We understand the frustration of some citizens of other EU Member States, resident in the UK, who have been finding they are unable to vote today when they wish to do so.

“All eligible EU citizens have the right to vote in the EU elections in their home Member State.

“If an EU citizen instead chooses to vote in the EU election in the UK, there is a process for them to complete to essentially transfer their right to vote, from their home Member State to the UK.

“This is a requirement of EU law, which specifies that this has to be done ‘sufficiently in advance of polling day’.

“UK law sets this as 12 working days in advance of the poll.”

It added: “This legal process could be made easier for citizens, and the Commission made the case for doing so following the last EU elections in 2014.

“However, improvements to the process are reliant on changes to electoral law, which can only be taken forward by Government and Parliament.

“The very short notice from the government of the UK’s participation in these elections impacted on the time available for awareness of this process amongst citizens, and for citizens to complete the process.”