Two buses burst into flames during Monday afternoon’s rush hour after an explosive device was detonated in one of the vehicles. More than 20 people were injured, two seriously, in what security officials called a terrorist attack.

Israeli police said a bomb was responsible for the fire, which consumed one bus and badly damaged the second, smashing its windows and shredding its metal skin. An hour after the explosion, the bus with the bomb was a smoldering, blackened shell.

The explosion on a public bus immediately brought back memories of the Palestinian uprising in the early 2000s, when bus bombings and suicide attacks were common.

Brachie Sprung, a spokeswoman for the Jerusalem mayor, told Reuters that the explosive device was “small, but it was definitely a bomb.” Israeli police declined to describe the device.

Israeli officials said they were investigating how the device got on the bus, who planted it and how it was detonated. They promised the investigation would move forward rapidly as police look through surveillance tapes and other evidence, including the identities of injured passengers.

Israelis have been hopeful that a six-month wave of Palestinian attacks was subsiding. There had been just three attacks in April, compared with 20 in March and 78 in October, when the current surge in assaults began.

“We will reach the perpetrators and those who support them and ensure those who stand behind it are held accountable,” said Prime Minister Benjamin Netanyahu.

Daniel Katzenstein, a medic who arrived at the scene while the buses were still burning, said that “it was eerily familiar from the days of the bus bombings” more than a decade ago. He said the victims were being rushed to hospitals, suffering from burns, lacerations and shrapnel wounds. “It was mayhem,” he said.

Bus bombings were a hallmark of the second Palestinian intifada, or uprising, from 2000 to 2005, and many people did all they could to avoid using public transportation. About 1,000 Israelis and 3,000 Palestinians were killed during the uprising.

The violence of recent months has left many Israelis — and Palestinians, too — anxious and exhausted.

Just hours before news of the bus bombing broke, the Israeli military announced it had discovered and destroyed an offensive tunnel dug by the Islamist militant movement Hamas. The tunnel stretched from the Gaza Strip into Israel. It was the first to be uncovered since the end of the 2014 Gaza war between Israel and Hamas.

Also Monday, military prosecutors formally charged an Israeli soldier with manslaughter in the killing of a prone Palestinian attacker — an act caught on video.

Israeli human rights activists decried the killing as an execution, but many Israelis have defended the shooting as justified or called it a mistake that should have been dealt with as an infraction.

Military prosecutors, however, say the shooting was a serious breach. Sgt. Elor Azaria, 19, shot the Palestinian, Abdel Fattah al-Sharif, in the head as he lay on his back in the street in Hebron felled by six bullets, wounded but still alive.

In a small crowded courtroom in Jafa, the prosecutor read aloud from an indictment that stated that Azaria fired “in violation of rules of engagement and without operational justification, while al-Sharif lay wounded on the ground . . . and did not pose immediate and clear threat to the defendant, civilians or soldiers in the area.”

Azaria’s defense attorneys countered that their client suspected that Sharif was concealing a suicide vest.

One of his attorneys, Eyal Besserglick, said his client “felt a real and present danger to his life and those around him.”

“He doesn’t deserve to be one day in jail,” Besserglick said. “He was acting in self-defense.”

Supporters of the solider are planning a large rally, with music and speeches, in Tel Aviv on Tuesday night. Many Israelis have described Azaria as a hero.

Military prosecutors have collected evidence that Azaria initially mentioned nothing about fearing for his life. Instead, he told fellow soldiers at the scene that Sharif “deserves to die.”

The last soldier to be successfully prosecuted for manslaughter was sentenced to eight years in 2005 for shooting a British peace activist in Gaza in 2003.