A gunman attacked school no. 175 in the city, about 500 miles east of Moscow, on Tuesday morning while hundreds of children were in classes. Armed with a semi-automatic shotgun and explosives, the attacker forced his way into the building and made his way to classrooms and opened fire on eight graders there, according to police.
Heavily armed police stormed the school and detained the alleged shooter, identified as a 19-year-old man.
Videos from the scene showed terrified children trying to flee the school building, with some jumping out of high windows as the sound of gun shots rang out. Emergency services helped others to climb down ladders. Other videos showed children lying in grass near the school covered in blood.
"It's a great tragedy. We have lost seven children -- four boys, three girls. They died here on the third floor," Tatarstan's president, Rustam Minnikhanov, told reporters standing outside the school following the shooting. He said two female teachers at the school were also killed.
The seven children killed were eighth graders. At least 21 people were hospitalized, 18 of them children, and six are in critical condition, according to regional health authorities. Most of the children are between the ages of 7 and 15.
Children at the school described to Russian media how they locked themselves in their classrooms on the third floor after hearing explosions and gunfire. In several accounts, students said the gunman tried to break down the doors to get to them.
"He sort of started to smash the door," a pupil, identified as Adelya, told the Russian news site Media.Zona. "Then the police came into the corridor. He ran and started shooting, and a bullet hit our door."
Authorities identified the attacker as Ilnaz Galyaviyev, a resident of Kazan and according to local media a former pupil at the school. There were early conflicting reports suggesting two gunmen were present at the attack, but local authorities have since said he acted alone.
Russian media have found a channel on the Telegram messenger purportedly created by the alleged shooter a few days before the attack. In photos posted on the channel, a man poses in a long, dark coat and a mask with the word "God" written in Russian on it. In the posts, the alleged gunman refers to himself as a "god" and threatened mass killings in the near future.
After police said they had detained the shooter, local media posted a video purporting to show Galyaviyev's interrogation by police. In the video, a young man, shirtless and tied by his arms and legs to a cage, screams at an officer that he has realised he "is a god" and that he "hates everyone."
Galyaviyev until last month was a student at a college in Kazan but dropped out in April, the college told the Russian news site, RBC. He graduated from the school four years ago and had been studying programming at the college.
Russian officials said that Galyaviyev obtained a gun license last month, using it to buy the semi-automatic shotgun used in the attack.
Although in recent years there have been a series of deadly attacks at schools by students in Russia, mass school shootings of the sort seen in the United States are rare and this is already one of the most deadly. In 2018, an 18-year-old killed 20 people and injured dozens more before killing himself at a school in Kerch in Crimea.
President Vladimir Putin expressed condolences to the victims on Monday and immediately ordered authorities to tighten up gun regulations.
Putin's spokesman Dmitry Peskov said Putin had ordered the head of Russia's National Guard that oversees gun ownership to develop new rules for the type of weapons civilians are permitted to possess. Peskov said the change was needed to address to assault weapons sometimes being improperly classed as hunting rifles.
Following Putin's order, Russia's National Guard quickly said it would develop new rules in coordination with other government bodies and the head of Russia's parliament, Vyacheslav Volodin, said it would meet next week to discuss measures for tougher controls, including ensuring stricter background checks. Volodin also said the parliament should discuss whether anonymity on the internet now ought to be restricted.
Tatiana Moskalkova, Russia's human rights ombudswoman, called for the age for purchasing firearms to be raised from 18 to 21, except for those with military experience.
Russia has fairly tough gun laws, requiring potential owners to take classes and pass a series of tests, including medical and psychological examinations, before they can receive a license to buy smoothbore guns, such as shotguns. To buy a rifle requires another five-year waiting period following that.
After the 2018 Kerch school shooting, Putin also ordered the National Guard to tighten firearm rules. But since then, proposed plans -- including to have gun owners inform the guard of their location within three days if they travel with their weapons -- have stalled and little has changed, according to the Russian news sites Meduza and Kommersant.