MOSCOW — An 18-year-old student strode into his vocational school in Crimea, a hoodie covering his blond hair, then pulled out a shotgun and opened fire on Wednesday, killing 19 students and wounding more than 50 others before killing himself.

It wasn't clear what prompted Vladislav Roslyakov, described as a shy loner, to go on the rampage. A security camera image carried by Russian media showed him calmly walking down the stairs of the school in the Black Sea city of Kerch, the shotgun in his gloved hand.

"He was walking around and shooting students and teachers in cold blood," said Sergei Aksyonov, the regional leader in Crimea.

Officials said the fourth-year student killed himself in the library of the Kerch Polytechnic College after the attack. His mother, a nurse, was helping to treat victims at a local hospital after the shootings, unaware yet that her son was accused of the rampage and was already dead.

Such school shootings are rare, and Wednesday's attack was by far the worst by a disgruntled student in Russia, which annexed the Crimean Peninsula from Ukraine in 2014. The bloodbath raised questions about school security in the country; the Kerch Polytechnic College had only a front desk with no security guards.

By the end of the day, Crimean authorities said the death toll stood at 19, apparently not including the shooter. Fifty-three people were wounded, including 12 in serious condition.

It was the greatest loss of life in school violence in Russia since the Beslan terrorist attack by Chechen separatists in 2004, in which 333 people were killed during a three-day siege, many of them children, and hundreds were wounded.

The announcement that the shooter in Wednesday's attack was a student who acted alone came after hours of rapidly shifting explanations as to what exactly happened at the school.

Officials at first reported a gas explosion, then said an explosive device had ripped through the cafeteria during lunchtime in a suspected terrorist attack.

Witnesses, however, reported that victims were being killed by gunfire. The Investigative Committee, Russia's top crime investigation agency, eventually said all the victims died of gunshot wounds.

Reflecting the daylong confusion, Russian President Vladimir Putin said the victims were killed by an explosion just as the Investigative Committee was announcing they were fatally shot.

A somber-faced Putin deplored the attack as a "tragic event" and offered his condolences to the victims' families at a news conference in the southern city of Sochi, where he was meeting with Egyptian President Abdel-Fattah el-Sissi.

The Investigative Committee said the explosive device rigged with shrapnel went off in the school lunchroom and Sergei Melikov, a deputy chief of the Russian National Guard, said it was homemade. Officials later found a second explosive device and destroyed it.

It was not clear what the explosive was, if the attacker detonated it, or how many people it wounded.

Guns are tightly restricted in Russia. Civilians can own only hunting rifles and smooth-bore shotguns and must undergo significant background checks. Roslyakov had only recently received a permit to own a shotgun and bought 150 cartridges just a few days ago, according to local officials.

Aksyonov, the regional leader in Crimea, said the gunman had been described as a shy boy who had no conflicts.

"He wasn't aggressive, he was rather timid," Aksyonov said, speculating that Roslyakov might have "watched some movies" that inspired him to go on the shooting spree.

Some Russian news reports said the shooter had left his backpack containing the explosive device in the cafeteria and remotely detonated it before he started shooting.

"I heard an explosion and saw glass shards and window frames falling down," student Roman Voitenko said in remarks broadcast on Russian state television.

Another student, Semyon Gavrilov, said he had fallen asleep during a lecture and was awakened by the sound of shooting. He looked around and saw a young man shooting at people, he said.

"I locked the door, hoping he wouldn't hear me," Gavrilov told the Komsomolskaya Pravda newspaper.

He said police arrived about 10 minutes later to evacuate people and he saw dead bodies on the floor and charred walls.

Another student, Yuri Kerpek, told the state RIA Novosti news agency that the shooting went on for about 15 minutes.

Russia has seen several violent attacks by students in recent years, but none of them were even remotely as brutal as the Kerch rampage.

Early this year, a teenager armed with an ax attacked fellow students at a school in Buryatia in southern Siberia, wounding five students and a teacher. The attacker also ignited a firebomb in the class and tried to kill himself before being apprehended.

In another attack in January, two teenagers stabbed children and their teacher with knives, wounding 15 people, and then attempted to kill each other before being detained.

After Wednesday's attack, local officials declared a state of emergency on the Black Sea peninsula and cordons of Russia's National Guard circled the school. Security was also increased at a new 19-kilometer (12-mile) bridge linking the peninsula with Russia, which opened earlier this year. Military units were deployed near the college to help emergency agencies.

Russia's 2014 annexation of Crimea triggered Western sanctions. Russia has also supported separatists fighting the Ukrainian government in eastern Ukraine, a conflict that has left at least 10,000 people dead since 2014.

Over the past few years, Russian security agencies have arrested several Ukrainians accused of plotting terror attacks in Crimea, but no attacks have occurred.