LONDON — A man who stabbed a veteran British lawmaker to death last year while he was meeting with voters was a “committed Islamist terrorist” who had spent years researching and planning potential attacks on lawmakers, a prosecutor said Monday.

Ali Harbi Ali, 26, appeared in the dock Monday at London’s Central Criminal Court as a trial opened into the murder of Conservative lawmaker David Amess, who was attacked on Oct. 16 during a routine meeting with constituents in a church hall in the town of Leigh-on-Sea in eastern England.

Ali, a London man with Somali heritage, denies charges of murder and preparing acts of terrorism.

Opening the trial, prosecutor Tom Little said the case was “nothing less than an assassination” carried out because of a “warped and twisted and violent ideology.”

“It was a murder carried out by that young man who for many years had been planning just such an attack and who was, and is, a committed, fanatical, radicalized Islamist terrorist,” he said.

Little said Ali bought the knife used to attack Amess five years earlier, and that Ali tricked his way into meeting Amess by pretending to be one of his constituents.

Amess, 69, had been a member of Parliament since 1983, and was one of the most prominent Catholics in the House of Commons. He was pronounced dead at the scene after the stabbing. Little alleged that Ali told others immediately after the slaying that he wanted politicians who had agreed to the “bombing of Syria” and the war in Iraq to die.

The prosecutor also said that Ali had researched and planned attacks on lawmakers and the Parliament building from at least 2019. The research included reconnaissance trips targeting work and home addresses of two other lawmakers, Mike Freer and Cabinet member Michael Gove, he added.

The trial is expected to last for three weeks.

The slaying of Amess shook the nation and sparked calls for increased police protection for politicians as they carry out their work. It came five years after Labour Party lawmaker Jo Cox was shot and stabbed to death by a far-right extremist.

Crux staff contributed to this report.