A Russian court on Wednesday ordered that a teenager accused of killing nine pupils and staff in a school shooting spree be held in pre-trial detention, as his victims were laid to rest.

On Tuesday, a lone gunman identified as 19-year-old Ilnaz Galyaviev opened fire at School No. 175 in the central Russian city of Kazan, armed with a shotgun and at least one improvised explosive device.

Russia has relatively few school shootings, and the tragedy has sent shock waves across the country.

Mourners carry the casket of teacher Elvira Ignatyeva, who was killed in the shooting
Mourners carry the casket of teacher Elvira Ignatyeva, who was killed in the shooting AFP / NATALIA KOLESNIKOVA

A court in Kazan on Wednesday ordered that Galyaviev, who investigators say suffers from a brain disorder, be held in pre-trial detention for two months.

The suspect, who was dressed in black and wore handcuffs, looked calm in court.

An investigator in the case said Galyaviev had been formally charged with murder and pleaded guilty.

Russians in Kazan mark day of mourning after school shooting
Russians in Kazan mark day of mourning after school shooting AFPTV / Andrey BORODULIN

Earlier in the day the nine students and staff killed in the shooting spree were laid to rest while nine of the wounded were flown to Moscow for treatment.

Flags were flaying at half-mast throughout Kazan, the capital of the majority Muslim Russian region of Tatarstan.

Black-clad family members and students of Elvira Ignatieva -- a 26-year-old English teacher who reportedly died while shielding pupils from the gunman -- laid flowers and read the Koran at her grave during a funeral ceremony.

Map locating Kazan in Russia, and School N°175 where the deadly shooting took place
Map locating Kazan in Russia, and School N°175 where the deadly shooting took place AFP / Paz PIZARRO

"My niece was like a shining star: she took off, lit up and faded away," her aunt Anna Ignatieva told AFP, crying and wearing a black scarf.

Dozens of mourners carrying flowers and soft toys also congregated outside the school to commemorate the dead.

"This is a huge and unexpected loss," Irina Krasnikova told AFP.

"We live in such a nice city. It's hard to believe this happened to us," she added.

Wednesday was declared a day of mourning after the shooting
Wednesday was declared a day of mourning after the shooting AFP / Yuri KADOBNOV

"It didn't happen to my children, but it is so painful, it's hard to speak."

Galyaviev has been described as a former student at the school who was recently dismissed from a local technical college for poor grades.

The shooting took place in School No. 175 in Kazan
The shooting took place in School No. 175 in Kazan AFP / NATALIA KOLESNIKOVA

Svetlana Petrenko, a spokeswoman for the Investigative Committee, which probes major crimes, said Wednesday that Galyaviev suffered from a brain disorder and had repeatedly sought medical attention for severe headaches.

"His family has also noticed aggression and a quick temper in his behaviour since the beginning of this year," she said.

On Tuesday, panic spread throughout the building, with some students jumping from windows to escape, as the attack took place.

The gunman was detained within about an hour, and Galyaviev was later shown in interrogation footage leaked online claiming he was God and that he had "a monster" inside him.

All the children killed were in Ignatieva's eighth-grade class and believed to be aged 13 and 14. The second staff member killed was a teaching assistant for younger students.

Twenty children, including some who sustained injuries while attempting to escape the school building, were being treated in hospital, regional authorities said on Wednesday, as were three adults.

Two students were in a critical condition.

After the attack, President Vladimir Putin offered condolences to the families of the victims and urged lawmakers to make the process of legally obtaining a firearm more strict.

The shooting also prompted calls among pro-Kremlin lawmakers for even tighter regulation on the internet, which opposition figures in Russia say authorities use to suppress political dissent.

The speaker of the lower house of parliament, Vyacheslav Volodin, called on lawmakers to discuss the possibility of removing internet anonymity by requiring users to identify themselves to be allowed online.

Authorities have claimed that young Russians are being increasingly exposed to negative influences online, especially from the West.

The Russia-born founder of encrypted messenger Telegram, Pavel Durov, said Wednesday that his team had "acted quickly" to block the gunman's account, one hour after receiving initial complaints over his channel.

Buying firearms legally is not easy in Russia, although it is possible to register hunting rifles.

Officials noted that Galyaviev had undergone security and psychological tests to gain a license for the weapon.

Though public shootings are rare in Russia, Tuesday's attack follows similar incidents in recent years.

In October 2018, another teenage gunman -- reportedly using the same type of weapon as Galyaviev -- killed 20 people at the Kerch technical college in Crimea, the peninsula Russia annexed from Ukraine in 2014.