Two children could be seen leaping from the third floor of the four-storey School Number 175 to escape as gunshots rang out, in a video filmed by an onlooker that was circulated by Russia's RIA news agency.
Calling the attack a big tragedy for the whole country, Rustam Minnikhanov, the head of the wider Tatarstan region, said there was no evidence that anyone else had been involved.
"We have lost seven children...four boys and three girls. And 16 people, 12 children and four adults, are in hospital," Minnikhanov told state TV. "The terrorist has been arrested. He's a 19-year-old who was officially registered as a gun owner."
Kazan is the capital of the Muslim-majority region of Tatarstan and located around 450 miles (725 km) east of Moscow.