A far-right extremist screamed "This is for Britain" when he killed MP Jo Cox in a "cowardly" attack at the height of the EU referendum campaign, a court heard.
Thomas Mair (aged 53) allegedly repeatedly shot and stabbed the 41-year-old Labour politician outside her constituency surgery in Birstall, near Leeds, on June 16.
Opening his Old Bailey trial, Richard Whittam QC told jurors how mother-of-two Mrs Cox had supported the Remain campaign leading up to the referendum on June 23.
On the afternoon of Thursday June 16 2016, she was to hold a surgery in the library in Market Street, having visited a local school and a care home.
As she arrived, Mair launched his "cowardly" gun and knife attack, Mr Whittam said.
Mrs Cox was shot three times and suffered 15 stab wounds, jurors were told.
Mair was allegedly heard by a number of witnesses to shout repeatedly "Britain First".
During the attack, a 77-year-old local man risked his own life in an effort to save hers, the court heard.
Bernard Carter-Kenny was stabbed once by Mair with the same knife that he used to stab Mrs Cox, the prosecutor said.
Emergency services arrived within minutes and she was given an emergency thoracotomy as she lay in the street, the court heard.
Mr Whittam told jurors that Mair carried out his "pre-meditated murder" for an ideological cause.
Items found at Mair’s home in Lowood Lane, Birstall, showed he had "strong political and ideological interests", Mr Whittam said.
The court heard that Mair had used the computers at the same library in the weeks leading up to the killing to access websites.
In May, Mair accessed the Wikipedia page of "far right" online publication Occidental Observer which covers "politics and society from a white nationalist and anti-Semitic perspective", the court heard.
On June 13, he looked at the Twitter and Wikipedia pages for Mrs Cox, and the Wikipedia page for Conservative Ian Gow, whose killing by the IRA made him the last sitting MP to be murdered until that point, jurors were told.
He went on to view information about former foreign secretary William Hague, another Yorkshire-based Remain supporter.
Mr Whittam said Mair also looked at information on .22 gun ammunition, including answers to the question: "Is a .22 round deadly enough to kill with one shot to a human head?"
The next day, Mair looked at websites on "matricide" - the murder of your own mother - Nazi material, the death penalty in Japan, political prisoners and the human liver and spinal column.
Jurors saw CCTV footage from the library showing Mair arriving to use the computers on June 15, the eve of the attack.
The prosecution alleges that late that afternoon he researched right-wing politicians as well as the Ku Klux Klan and civil rights activists killed by its supporters.
Mr Whittam said Mair also accessed sites covering "Israel and prominent Jewish individuals", Palestine, coffins, the Waffen-SS and more information on .22 ammunition.
On the morning of the killing, Mair was seen by a neighbour leaving his home wearing a white baseball cap, green jacket and dark trousers.
Jurors were shown more CCTV footage of him making his way along the road.
Mrs Cox arrived for her surgery with her manager Fazila Aswat and senior caseworker Sandra Major at 12.50pm.
Mair launched his attack two minutes later in front of shocked passersby.
Mr Whittam described it as a "dynamic, fast-moving and shocking incident".
Shelly Morris, who was the first to call 999, reported hearing "a loud bang like a popping sound" and "a loud piercing scream", jurors were told.
She allegedly saw a man with a large steak knife with a jagged blade, which he wielded in a "stabbing motion".
The attacker stood over a figure and fired a gun twice, according to her account.
Ms Aswat saw Mair come up behind the MP and stab her, then shoot her with the gun.
He proceeded to attack Mrs Cox and Mr Carter Kenny with the knife before firing again at the politician, Mr Whittam said.
Ms Aswat hit Mair repeatedly with her handbag but was forced to retreat.
She allegedly heard the defendant shouting: "This is for Britain, Britain will always come first."
Ms Major heard him say "we’re British independence" and "Keep Britain independent", jurors were told.
Mair denies Mrs Cox’s murder, possession of a firearm with intent to commit an indictable offence and possession of an offensive weapon - a dagger.
Mair also pleads not guilty to causing grievous bodily harm with intent to Bernard Carter-Kenny on the same date.