LONDON — A 25-year-old man pleaded not guilty on Tuesday to murdering a British lawmaker who was stabbed to death while meeting constituents.

Conservative member of Parliament David Amess, a prominent Catholic member of the UK Parliament, was attacked Oct. 15 during a routine meeting with voters in a church hall in the town of Leigh-on-Sea in eastern England.

Prosecutors have charged Ali Harbi Ali, a London man with Somali heritage, alleging that the killing was an act of terrorism.

They say that before the killing Ali carried out reconnaissance on possible targets to attack, including lawmakers’ addresses and the Houses of Parliament.

Ali denied charges of murder and preparing acts of terrorism during a hearing at London’s Central Criminal Court. He was ordered detained until his trial, due to start March 21.

Amess was 69 and had been a member of Parliament since 1983. His slaying shook a nation accustomed to face-to-face contact with lawmakers, heightened concerns about extremism and rattled British politicians, who say they face increasing levels of vitriol and abuse as they perform their jobs.

The slaying came five years after Labour Party lawmaker Jo Cox was shot and stabbed to death by a far-right extremist. Cox was the first British lawmaker to be killed since a peace accord ended large-scale Northern Ireland violence almost 30 years earlier.