A loner obsessed with Nazis and extreme right-wing ideology was sentenced on Wednesday to spend the rest of his life in prison for murdering lawmaker Jo Cox in a frenzied street attack that stunned Britain a week before the European Union referendum.

Armed with a sawn-off rifle and a dagger, Thomas Mair, 53, shot Cox three times and repeatedly stabbed the 41-year-old mother of two young children in her northern English electoral district as she arrived for a meeting with local residents.

During the June 16 attack, he shouted "Britain first" and "Keep Britain independent," his trial heard. When arrested he told officers he was a political activist and his only words in court were when he gave his name as "death to traitors, freedom for Britain.