A senior Scottish nationalist has called on his party to ban members from having anonymous "Cybernat" accounts.

MEP Alyn Smith has proposed a new online code of conduct for the SNP - and called on rivals to follow suit - as a first step to cleaning up Scotland's often brutally tribalistic social media wars.

Mr Smith was speaking after a series of scandals on Twitter and Facebook exposed the real identities of both pseudonymous "cybernats", the nickname for problematic internet independence supporters, and their unionist counterparts.

The MEP said: "I would like to see a specific code of conduct in my own party with four or five simple points that everyone agrees on, including a ban on the kind of anonymous accounts which seem to enable people to be so unpleasant.

"I also think all the parties, either through their leaders or their chief executives, could sign some kind of code of online decency. As an out-gay pro-European nationalist I am no stranger to abuse but I am fed up of whataboutery from one side or another."

All parties already have codes of conduct they can use to discipline members, including elected politicians, who bring them in to disrepute. Mr Smith believes specific rules should be adopted for how people behave on social media platforms.

His views come after the Conservatives in May were forced to act against two newly elected Stirling councillors, Alistair Marjury and Brian Roberts, who had respectively made sectarian and racist remarks using anonymous accounts before taking office.

Mr Marjury, who also boasted of his penis size on a fetish dating site, hid behind an anonymous account to refer "tarriers" - a derogatory term for Catholics - make sectarian jokes and routinely equate the SNP to Nazis.

Previously the SNP candidate for Edinburgh South, Neil Hay, was outed during the 2015 general election campaign as the power behind an anonymous Twitter profile called Paco McSheepie which suggested unionists were like Nazi collaborators. Mr Hay was defeated at the polls. Another senior SNP activist was revealed as being behind attacks on the late Liberal Democrat MP Charlie Kennedy.

First Minister Nicola Sturgeon is among several prominent leaders urging better behaviour online after many politicians, especially women, suffered abuse and threats. Police have been investigating numerous online threats against the first minister, including from an anonymous self-identifying UKIP member calling for her assassination. Other female victims include former SNP MP Tasmina Ahmed-Sheikh and, south of the border, the Conservatives' Anna Soubry and Labour's Diane Abbott.

Mr Smith acknowledged that policing anonymous accounts was difficult and that his proposed rules would do nothing for those extremists who were not members of parties. But he believes many party members would think twice about being anonymous online if this was outlawed. Those caught breaching the rules would face internal party discipline, up to and including expulsion.

The MEPs remarks were an expansion of an essay in yesterday Sunday Herald in which he lambasted an online attitude where "everything my team says is correct and anything your team says is a cynical distortion of the truth.

He wrote: "I think we are at the point where some on the edges of Scotland's online activity have turned into tribalism, or worse, sectarianism. I think there is also the proven tactic of using abuse to shut down debate (I am looking at you, President Trump) being practised in Scottish cyberspace too. If the extremists and blowhards polarise discussion and drive regular folks offline, we all lose."

The Herald asked Scotland's second and third biggest parties, Conservatives and Labour to comment on Mr Smith's proposals. Tory MSP Finlay Carson said: "Social media is a fantastic communication tool which has many benefits, but it’s also important we face up to the negative side it has brought too.

“It’s easy to see that the abuse dished out online can often get out of hand, and it’s incumbent on all of us to be more civil and use social media in the correct manner.

“Disagreement and debate can be good, but it must not cross the line.”

A spokesman for Labour said: "All forms of abuse are unacceptable, including online abuse."