The man accused of murdering the Labour MP Jo Cox gave his name as “death to traitors, freedom for Britain” at his first court appearance, where it was revealed that he allegedly told police officers that he was a political activist when they arrested him.

Thomas Mair, 52, from Birstall, West Yorkshire, appeared at Westminster magistrates court in London to be charged with murder, grievous bodily harm, possession of a firearm with intent to commit an indictable offence, and possession of an offensive weapon.

Asked to confirm his name, Mair told the court: “My name is death to traitors, freedom for Britain.” The judge subsequently asked the defendant’s lawyers to confirm that his name was Thomas Mair, which they did.

Cox, the MP for Batley and Spen, was killed on Thursday outside Birstall public library, where she had been planning to run a constituency surgery, the court was told. The 41-year-old mother of two was declared dead at 1.48pm after being shot three times and repeatedly stabbed.

David Cawthorne, from the counter-terrorism division of the Crown Prosecution Service, told the court that Cox had visited a primary school and care home on Thursday morning, before heading to the library with colleagues for a surgery with her constituents. She was stabbed and fell to the ground, where she was shot and stabbed again.

Mair is alleged to have said “Britain first”, “this is for Britain”, “Britain always comes first” and “keep Britain independent” as he attacked the MP, prosecutors said.

Bernard Kenny, 77, was waiting for his wife in his car outside the library at the time of the attack, Cawthorne said. Kenny recognised Cox and saw a man approach and stab her. He intervened and was himself stabbed in the abdomen, forcing him to retreat into a nearby shop, the court heard.

Mair told police he was a “political activist” as he was arrested a mile from the scene, the prosecution said. Officers said the accused said “it’s me” when he was confronted; he was then tackled to the ground, handcuffed and searched. During the arrest, Mair also confirmed his name.

Searching Mair’s pockets, officers found a plastic bag containing bullets. They also found a single-barrelled firearm, along with a bloodstained mobile phone, a dagger and a black wallet, the court heard.

A written summary of the prosecution’s case revealed the findings of a search of the defendant’s house. Newspaper articles relating to Cox and ideological material relating to extreme rightwing and white-supremacist organisations and individuals were recovered from the property.

Mair remained silent when asked for his address and date of birth, and was handcuffed to a guard in the dock during the hearing. He was not required to enter a plea and Keith Allen, his lawyer, said there was no indication of what plea would be given. Allen also told the court an application for legal aid had been made.

The deputy chief magistrate Emma Arbuthnot ordered that Mair be remanded in custody at Belmarsh prison until his next appearance, which will be at the Old Bailey on Monday. Arbuthnot also suggested that a psychiatric report be prepared. “Bearing in mind the name he has just given, he ought to be seen by a psychiatrist,” she said.