An alleged terrorist accused of murdering veteran MP Sir David Amess told a court he wanted to kill a politician to stop him “harming Muslims” in Syria.

Ali Harbi Ali, 26, told jurors at the Old Bailey he wanted to “make hijrah”, to travel and fight in support of the terrorist organisation Islamic State, but he found it too difficult to get there.

The 26-year-old stands accused of stabbing the Conservative MP more than 20 times at Belfairs Methodist Church in Leigh-on-Sea, Essex, shortly after midday on October 15 last year where Amess died at the scene.

The prosecution alleges that Ali was motivated to commit the attack because of a grievance with MPs who voted in favour of bombing Syria. His previous alleged targets included Cabinet minister Michael Gove.

Giving evidence from the witness stand on Thursday, Ali said he decided to kill Amess because of his previous voting record on the UK’s foreign policy, including airstrikes on Syria.

Ali told the court: “I decided to do it because I felt that if I could kill someone who made decisions to kill Muslims, it could prevent further harm to those Muslims.

“He voted previously in Parliament, not just him… I decided if I couldn’t make hijrah, if I couldn’t help the Muslims (in Syria), I would do something here.”

Asked what difference killing the MP would make, Ali said: “For one, he can’t vote again.

“If he had previous for doing votes like that he won’t do it in the future, and perhaps send a message to his colleagues.”

Ali was asked why he had a note on his phone about his “plans” to kill Mr Gove.

Ali said: “That was plans I had to attack and hopefully kill Michael Gove at the time.

“I believe he was someone who was a harm to Muslims.

“I thought if I couldn’t go join Islamic State, I should try and do something here to help Muslims here.”

Ali said he “deeply” regretted not being able to join the terrorist group and did not think the attack was wrong.

“If I thought I did anything wrong, I wouldn’t have done it,” he said.

Seeking to justify his actions on the day, he added: “I consider myself a Muslim who went out and killed someone who killed Muslims.”

Prosecutor Tom Little QC asked: “You don’t regard yourself as a radical?”

Ali replied: “I am a moderate Muslim.”

Ali had managed to arrange an appointment with Amess, 69, by duping the politician’s office into believing he was a healthcare worker moving to the area and wished to discuss local matters.

The trial previously heard how Ali allegedly spent years hatching his plot, researching a number of potential high-profile political targets including Mr Gove, Dominic Raab and Sir Keir Starmer, before settling on Amess.

Ali, from Kentish Town in north London, denies preparing terrorist acts and murder.

The trial was adjourned until Monday for closing speeches.