LONDON — A man accused of stabbing a British lawmaker to death during a regular meeting with his constituents told a court Thursday he targeted the politician because he voted for air strikes on Syria.

Ali Harbi Ali, 26, is accused of murdering veteran Conservative lawmaker David Amess on Oct. 15 during a routine meeting with voters in a church hall in the town of Leigh-on-Sea in eastern England. Ali, who stabbed Amess repeatedly with a carving knife, denies charges of preparing acts of terrorism and murder.

Giving evidence Thursday, Ali said he decided to take action in the UK to help Muslims in Syria because he couldn’t join the Islamic State group.

“He voted previously in Parliament, not just him,” he said. “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.”

Ali, who is from London, said he “deeply” regretted not being able to join the terrorist group and did not think the attack on Amess was wrong.

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

He added he had expected to be shot and die at the scene, but decided to drop his knife after seeing that the first police to arrive were not armed with guns.

Prosecutors allege Ali had spent years researching a number of high-profile politicians and carrying out reconnaissance on possible targets to attack, including lawmakers’ addresses and the Houses of Parliament in London.

They allege he managed to set up an appoint with Amess, 69, on the day he was killed by convincing the politician’s office that he had newly moved to the area and wanted to discuss local issues.

Amess was one of the most prominent Catholic members of the British Parliament.