Police officers walk with a dog near the site of Friday’s explosion in London.

LONDON – A homemade bomb planted in a rush-hour subway car exploded in London on Friday, injuring 29 people and prompting authorities to raise Britain’s terrorism threat level to “critical,” meaning another attack may be imminent.

The early morning blast sparked a huge manhunt for the perpetrators of what police said was the fourth terrorist attack in the British capital this year.

Prime Minister Theresa May, acting on the recommendation of the Joint Terrorism Analysis Center, raised the country’s threat level from “severe” to “critical” — its highest possible level. May said military troops would augment the police presence in a “proportionate and sensible step.”

Earlier, May said the device had been “intended to cause significant harm.”

Still, to the relief of authorities and Londoners, experts said 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 Islamic State claimed responsibility for the attack, which it said was carried out by an affiliated unit.

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.

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.”

“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.

An injured woman is assisted by a police officer close to Parsons Green station in west London. Associated Press/Dominic Lipinski/PA

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.

Speaking to reporters late Friday, Assistant Commissioner Mark Rowley said police were making “good progress” and that the public should be reassured that more police and troops will be on the streets.

“We are only aware of one device,” he said. “We have remnants of that device. We are chasing down suspects.” He refused to provide further details, except to say the bomb involved the “detonation of an improvised explosive device.”

Among the questions authorities were seeking 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.

People leave the scene of an explosion at a southwest London subway station Friday. Associated Press/@RRIGS

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.

The last time the country’s threat level was raised to critical, was 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.