An injured woman is assisted by a police officer close to Parsons Green station in west London after an explosion on a packed London Underground train, Friday, Sept. 15, 2017. London’s Metropolitan Police says a fire on the London subway has been declared a “terrorist incident.” (Dominic Lipinski/PA via AP)

LONDON — A homemade bomb planted in a rush-hour subway car injured 29 people in London on Friday, sparking a huge manhunt for the perpetrators of what police said was the fourth terrorist attack in the British capital this year.

Later Friday, the Islamic State group claimed that the London subway explosion was carried out by an affiliated unit, and Britain raised its terrorism threat level to critical — meaning another attack is expected shortly

Prime Minister Theresa May said the device “was intended to cause significant harm,” but to the relief of authorities and Londoners, the bomb — hidden in a plastic bucket inside a supermarket freezer bag — only partially exploded, sparing the city much worse carnage.

“I would say this was a failed high-explosive device,” Chris Hunter, a former British army bomb expert, said of the blast, which caused no serious injuries.

The bomb went off around 8:20 a.m. as the train, carrying commuters from the suburbs — including many school children — was at Parsons Green station in the southwest of the city.

A police vehicle blocks traffic after an incident on a tube train at Parsons Green subway station in London, Friday, Sept. 15, 2017. A reported explosion at the train station sent commuters stampeding in panic, injuring several people on Friday at the height of London’s morning rush hour, and police said they were investigating it as a terrorist attack. (AP Photo/Kirsty Wigglesworth)

An ambulance leaves a cordon after an incident on a tube train at Parsons Green subway station in London, Friday, Sept. 15, 2017. A reported explosion at the train station sent commuters stampeding in panic on Friday at the height of London’s morning rush hour. (Photo by Frank Augstein, AP)

Sound

The gallery will resume inseconds

People leave the scene of an explosion at a southwest London subway station in London Friday, Sept. 15, 2017. London’s Metropolitan Police says a fire on the London subway has been declared a “terrorist incident. (@Alex Littlefield via AP)

In this image made from video, fire burns at a southwest London subway station in London Friday, Sept. 15, 2017. London’s Metropolitan Police and ambulance services are confirming they are at the scene of “an incident” at the Parsons Green subway station in the southwest of the capital. The underground operator said services have been cut along the line. (@RRIGS via AP)

An injured woman is assisted by a police officer close to Parsons Green station in west London after an explosion on a packed London Underground train, Friday, Sept. 15, 2017. London’s Metropolitan Police says a fire on the London subway has been declared a “terrorist incident.” (Stefan Rousseau, PA via AP)

In this aerial image made from video, emergency workers help people to disembark a train near the Parsons Green Underground Station after an explosion in London Friday, Sept. 15, 2017. A reported explosion at a train station sent commuters stampeding in panic, injuring several people at the height of London’s morning rush hour, and police said they were investigating it as a terrorist attack. (Pool via AP)

Armed police close to Parsons Green station in west London after an explosion on a packed London Underground train, Friday, Sept. 15, 2017. (Dominic Lipinski/PA via AP)

A London evening newspaper stand displays their headline outside Paddington tube station in London, after a terrorist incident was declared at Parsons Green subway station Friday, Sept. 15, 2017. A bucket wrapped in an insulated bag caught fire on a packed London subway train early Friday, sending commuters running for safety at the height of the morning rush hour. (Andrew Matthews/PA via AP)

A police forensic tent stands setup on the platform next to the train on which a homemade bomb exploded at Parsons Green subway station in London, Friday, Sept. 15, 2017. Hundreds of London police embarked on a massive manhunt Friday, racing to find out who placed a homemade bomb on a packed London subway train during the morning rush hour. The explosion wounded people and caused a panicked stampede to safety. (AP Photo/Frank Augstein)

A police forensic officer stands at right near the train, at left, where an incident happened that police say they are investigating as a terrorist attack, at Parsons Green subway station in London, Friday, Sept. 15, 2017. A bucket wrapped in an insulated bag caught fire on a packed London subway train Friday, sending commuters stampeding in panic at the height of the morning rush hour. (AP Photo/Frank Augstein)

An injured woman is assisted by a police officer close to Parsons Green station in west London after an explosion on a packed London Underground train, Friday, Sept. 15, 2017. London’s Metropolitan Police says a fire on the London subway has been declared a “terrorist incident.” (Dominic Lipinski/PA via AP)

This is an image made from video showing burning items in underground train at the scene of an explosion in London Friday, Sept. 15, 2017. A reported explosion at a train station sent commuters stampeding in panic, injuring several people at the height of London’s morning rush hour, and police said they were investigating it as a terrorist attack. (Sylvain Pennec via AP)

In this aerial image made from video, police officers work at the Parsons Green Underground Station after an explosion in London Friday, Sept. 15, 2017. A reported explosion at a train station sent commuters stampeding in panic, injuring several people at the height of London’s morning rush hour, and police said they were investigating it as a terrorist attack. (Pool via AP)

Police and community support officers gather round a police vehicle near where an incident happened that police say they are investigating as a terrorist attack at Parsons Green subway station in London, Friday, Sept. 15, 2017. A bucket wrapped in an insulated bag caught fire on a packed London subway train Friday, sending commuters stampeding in panic at the height of the morning rush hour. (AP Photo/Kirsty Wigglesworth)

An injured woman is assisted by a police officer close to Parsons Green station in west London after an explosion on a packed London Underground train, Friday, Sept. 15, 2017. London’s Metropolitan Police says a fire on the London subway has been declared a “terrorist incident.” (Dominic Lipinski/PA via AP)

A police vehicle blocks traffic after an incident on a tube train at Parsons Green subway station in London, Friday, Sept. 15, 2017. A reported explosion at the train station sent commuters stampeding in panic, injuring several people on Friday at the height of London’s morning rush hour, and police said they were investigating it as a terrorist attack. (AP Photo/Kirsty Wigglesworth)

An armed police officer stands nearby after an incident on a tube train at Parsons Green subway station in London, Friday, Sept. 15, 2017. A reported explosion at the train station sent commuters stampeding in panic, injuring several people on Friday at the height of London’s morning rush hour, and police said they were investigating it as a terrorist attack. (AP Photo/Frank Augstein)

Police provide security at Paddington mainline train station in London, after a terrorist incident was declared at nearby Parsons Green subway station Friday, Sept. 15, 2017. A bucket wrapped in an insulated bag caught fire on a packed London subway train early Friday, sending commuters running for safety at the height of the morning rush hour. (Andrew Matthews/PA via AP)

Witness Chris Wildish told Sky News that he saw “out of the corner of my eye, a massive flash of flames that went up the side of the train,” followed by “an acrid chemical smell.”

Commuter Lauren Hubbard said she was on the train when she heard a loud bang.

“I looked around and this wall of fire was just coming toward us,” Hubbard said. She said her instinct was “just run,” and she fled the above-ground station with her boyfriend.

Chaos ensued as hundreds of people, some of them suffering burns, poured from the train, which can hold up to 800 people.

“I ended up squashed on the staircase. People were falling over, people fainting, crying. There were little kids clinging onto the back of me,” said another commuter, Ryan Barnett.

Passenger Luke Walmsley said it was “like every man for himself to get down the stairs.”

A map shows the location of incident at Parsons Green subway station in London. (The Associated Press)Photos taken inside the train show a white plastic bucket inside a foil-lined shopping bag. Flames and what appear to be wires emerge from the top.

“People were just pushing,” he added. “There were nannies or mums asking where their children were.”

Police and health officials said 29 people were treated in London hospitals, most of them for flash burns. None of the injuries were serious or life-threatening, the emergency services said.

Trains were suspended along a stretch of the Underground’s District Line, and several homes were evacuated as police set up a 50-meter (150-foot) cordon around the scene while they secured the device and launched a search for those who planted it.

The Metropolitan Police said hundreds of detectives, along with agents of the domestic spy agency MI5, were looking at surveillance camera footage, carrying out forensic work and speaking to witnesses.

Among questions they were rushing to answer: What was the device made from, and was it meant to go off when it did, in a leafy, affluent part of the city far from London’s top tourist sites?

British media reported that the bomb included a timer. Lewis Herrington, a terrorism expert at Loughborough University, said that would set it apart from suicide attacks like those on the London subway in 2005 or at Manchester Arena in May, in which the attackers “all wanted to die.”

Photos taken inside the train showed a white plastic bucket inside a foil-lined shopping bag, with flames and what appeared to be wires emerging from the top.

Terrorism analyst Magnus Ranstorp of the Swedish Defense University said that from the photos it appeared the bomb did not fully detonate, as much of the device and its casing remained intact.

“They were really lucky with this one, it could have really become much worse,” he said.

Hunter, the explosives expert, said it appeared that “there was a bang, a bit of a flash, and that would suggest that, potentially, some of the explosive detonated, the detonator detonated, but much of the explosive was effectively inert.”

Police and ambulances were on the scene within minutes of the blast, a testament to their experience at responding to violent attacks in London. The city has been a target for decades: from Irish Republican Army bombers, right-wing extremists and, more recently, attackers inspired by al-Qaida or the Islamic State group.

Britain has seen four other terrorist attacks this year, which killed a total of 36 people. The other attacks in London — near Parliament, on London Bridge and near a mosque in Finsbury Park in north London — used vehicles and knives. Similar methods have been used in attacks across Europe, including in Nice, Stockholm, Berlin and Barcelona.

In contrast Friday’s attack involved the “detonation of an improvised explosive device,” said Mark Rowley, head of counterterrorism for the Metropolitan Police.

After chairing a meeting of the government’s COBRA emergency committee, the prime minister said that Britain’s official threat level from terrorism remained at “severe,” meaning an attack is highly likely, and was not being raised to critical.

The country’s threat level was briefly raised to critical, meaning an attack may be imminent, after the May 22 suicide bombing at Manchester Arena that killed 22 people.

British authorities say they have foiled 19 plots since the middle of 2013, six of them since the van and knife attack on Westminster Bridge and Parliament in March, which killed five people. Police and MI5 say that at any given time they are running about 500 counterterrorism investigations involving 3,000 individuals.

London Mayor Sadiq Khan said there had been a “shift” in the terrorism threat, with attackers using a wide range of methods to try to inflict carnage. Khan, who belongs to the opposition Labour Party, said London police needed more resources to fight the threat. Police budgets have been cut since 2010 by Britain’s Conservative government.

The London Underground, which handles 5 million journeys a day, has been targeted several times in the past. In July 2005, suicide bombers blew themselves up on three subway trains and a bus, killing 52 people and themselves. Four more bombers tried a similar attack two weeks later, but their devices failed to fully explode.

Last year Damon Smith, a student with an interest in weapons and Islamic extremism, left a knapsack filled with explosives and ball bearings on a London subway train. It failed to explode.

U.S. President Donald Trump weighed in on Friday’s attack, tweeting that it was carried out “by a loser terrorist,” and adding that “these are sick and demented people who were in the sights of Scotland Yard.”

The British prime minister gently rebuked the president for his tweets.

“I never think it’s helpful for anybody to speculate on what is an ongoing investigation,” May said.

___

Gregory Katz in London and Lori Hinnant in Paris contributed to this report.