The wax ran in streaks on the sidewalk outside a school in Belgrade, left by the hundreds of candles lit by residents of the Serbian capital mourning the deaths of eight children gunned down by a 13-year-old classmate.

On Thursday, the morning after the shooting by a teenager armed with pistols he had taken from his father’s home, hundreds more people came to express their grief outside the school in an upscale neighborhood of Belgrade after the attack that also left a security guard dead.

Their eyes brimming with tears, they lit more candles, lay white flowers and hung messages scrawled on paper on fences near the Vladislav Ribnikar primary school in a central part of the Serbian capital.

“We’re all shocked and saddened,” said Luka Zivkovic, 18, a student from a nearby school who had come with dozens of schoolmates to pay his respects.

Mr. Zivkovic said he heard the gunshots from his school Wednesday morning and initially mistook them for the ignition of a truck. He then realized, after hearing the wail of police and ambulance sirens echo through the neighborhood, that a shooting had taken place.

“This is madness,” he said.

The shooting occurred on Wednesday morning, when the boy, who was in seventh grade, opened fire. Six children and a teacher were also injured in the attack and taken to the hospital. One girl who was wounded underwent emergency surgery overnight and was in critical condition Thursday, officials said.

Serbian officials revealed the identity of the boy at a briefing Wednesday, but The New York Times is withholding his name since he is a minor and has not been charged.

The attack sent shock waves through the country, which has experienced few mass shootings, let alone violence of this sort at a school. “Nobody thought this could happen here in this neighborhood, here in Serbia,” said Anita Lainovic, 45, who had come to the school with a pot of flowers to pay homage to the young victims.

Many residents wondered what might have driven the student to kill his classmates in what the police described as a planned, coldblooded attack. The student entered the school with two pistols belonging to his father and four Molotov cocktails, which he had prepared himself.

The student had accompanied his father to a shooting range in the past and knew how to shoot, Serbian officials said.

“How could such a profile be missed by everyone?” Ivana Savic, 49, asked. “What did his father teach him by taking him to the shooting range?”

President Aleksandar Vucic of Serbia said at a news conference Wednesday that the shooter had been arrested and taken to a mental health clinic, and that he “showed no remorse.” Serbian officials said the boy would not be held criminally responsible for the killings because is under the age of 14. But Mr. Vucic said he would propose changes in the age of criminal liability.

The boy’s parents have been arrested, the president said.

The shooting has raised broader questions about guns in Serbia, which has one of the highest rates of gun ownership in the world, a legacy of the Balkan wars of the 1990s.

A 2018 study by the Geneva-based Small Arms Survey research group estimated that there are about 39 guns for every 100 Serbians, the highest level in Europe and the fifth-highest in the world. The United States, which ranks first, has about 120 guns per 100 people.

Mr. Vucic of Serbia also promised on Wednesday to introduce a series of measures designed to better regulate guns, including setting a moratorium on new licenses other than for hunting, a revision of existing permits and enhanced surveillance of shooting ranges.

Ms. Lainovic said she agreed with the proposals, saying gun ownership was a lingering issue that has been poorly addressed over the years. “It’s part of our culture, it’s a legacy of the war,” she said. “But it can’t go on like this.”

Alisa Dogramadzieva contributed reporting.