LONDON—The fatal stabbing of a British lawmaker in a suspected terrorist attack on Friday shook the British political establishment and highlighted the continued challenges governments face against lone-wolf extremists armed with basic weapons.

On Saturday, police searched two homes in London as they sought to determine the motives of a 25-year-old man who allegedly stabbed lawmaker David Amess as he held a meeting with constituents in his district just east of the capital.

The...

LONDON—The fatal stabbing of a British lawmaker in a suspected terrorist attack on Friday shook the British political establishment and highlighted the continued challenges governments face against lone-wolf extremists armed with basic weapons.

On Saturday, police searched two homes in London as they sought to determine the motives of a 25-year-old man who allegedly stabbed lawmaker David Amess as he held a meeting with constituents in his district just east of the capital.

The British national is now in custody after being arrested at the site of the attack on suspicion of murder. The U.K. counterterror unit said in a statement early Saturday it wasn’t seeking any other suspects and that preliminary findings suggest “a potential motivation linked to Islamist extremism.”

Prime Minister Boris Johnson on Saturday morning laid flowers at the Methodist church where the 69-year-old Mr. Amess was stabbed multiple times.

Mr. Amess’s killing marks the second time in five years that a British lawmaker has died from a violent attack while appearing in public, raising questions as to how governments can protect people against low-tech attacks by individuals.

David Amess was killed as he was meeting with constituents.

Photo: TONY O'BRIEN/REUTERS

Several British politicians posted photos of themselves continuing to meet Saturday with constituents in person in a show of defiance.

Early indications were that the suspect wasn’t a subject of interest to the security services and hadn’t been involved in any closed investigations, according to a British official.

Home Secretary Priti Patel said the government is strengthening security measures for members of Parliament. “All measures are being put in place for the security of our [Members of Parliament] so that they can carry on with their duties,” she said.

The task of thwarting terrorist attacks has become more complicated in recent years as Islamic extremists shift toward attacks that are often inspired online, rather than being centrally coordinated or carefully planned, as was the case in some of the U.K.’s deadliest security breaches such as the 2017 suicide bombing at a music venue in Manchester and a series of bombings in London that left dozens dead in July 2005.

A vigil in memory of British lawmaker David Amess.

Photo: tolga akmen/Agence France-Presse/Getty Images

Last year the government said MI5, the country’s domestic spy agency, was actively investigating some 3,000 extremists in 600 separate probes. However MI5 believes there is a pool of around 40,000 people who aren’t considered an immediate threat but could potentially become active terrorists, according to a government report. Many of these aren’t based in the U.K.

In September, the director general of MI5 said that 31 late-stage terrorist attacks had been foiled in the U.K. over the past four years.

Following a number of low-tech terrorist attacks in recent years, including by individuals who had been released from prison, the U.K. this year tightened legislation to end the prospect of early release for anyone convicted of a serious terrorist offense.

The Counterterrorism and Sentencing Act also strengthened the tools available to counterterrorism police and the security services “to manage the risk posed by terrorist offenders and individuals of concern outside of custody.”

MI5’s Joint Terrorism Analysis Centre lowered the U.K.’s threat level earlier this year, from “severe” to “substantial,” meaning a terrorist attack remains likely.

“They’re obviously very difficult to predict because they can be launched at short notice with little logistical preparation required,” said Rakib Ehsan, a research fellow at the Henry Jackson Society, a U.K.-based think tank focused on security.

In 2020, three men were stabbed to death in a park in Reading, west of London, by a 25-year-old who was later described at trial as an Islamic extremist. In 2019, a convicted terrorist released from prison killed two people in a stabbing attack in the heart of London that highlighted the challenges faced by thinly stretched counterterrorism agencies in thwarting such attacks in the U.K. and Europe.

Norwegian authorities are investigating a bow-and-arrow attack that killed five people there this past week and have charged a Danish suspect who authorities said had converted to Islam and had been reported for radicalization.

British lawmakers have been targeted by extremists before. In 2016, a far-right extremist fatally stabbed and shot lawmaker Jo Cox shortly before she was to meet with locals in her district. The killing came just ahead of the Brexit referendum in which Britons voted to leave the European Union.

In 2010, a woman linked to an Islamic extremist stabbed Labour lawmaker Stephen Timms while he was meeting his constituents. The woman opposed Mr. Timms’s support for the Iraq war. Mr. Timms survived the attack. In the 1980s and 1990s several members of Parliament were attacked by the Irish Republican Army.

British members of Parliament customarily visit their home districts to meet with local constituents several times a month. They don’t normally have personal security details.

Mr. Amess had publicized the time and place of the meeting with his constituents on his Twitter page several days beforehand.

Lawmakers from across the political spectrum Saturday expressed shock and paid tributes to Mr. Amess, who was one of the longest-serving lawmakers in Britain’s Parliament, having served in the House of Commons for nearly four decades. Queen Elizabeth knighted him in 2015 for his political and public service. On Saturday dozens of well wishers left flowers outside the church where he was killed.

Write to Isabel Coles at isabel.coles@wsj.com and Max Colchester at max.colchester@wsj.com