The explosion tore through a train as it was traveling between two stations in Russia's second-largest city.
A second, larger device was found and defused at another station, Russia's Anti-Terrorism Committee said. No group has claimed responsibility for the attack, which led to the shutdown of the city's metro system.
Alongside the dead, 51 people were injured in the incident, according to CNN affiliate RBC.
President Vladimir Putin, who had been in St. Petersburg earlier in the day, laid roses at a makeshift memorial with candles outside the bombed metro station.
US President Donald Trump spoke briefly with Putin on Monday, according to a senior administration official. Trump expressed his sympathies for the Russian people in the wake of the terror attack.
Train conductor may have saved lives
The blast occurred just after 2:30 p.m. (7:40 a.m. ET) as the train was traveling in a tunnel from Sennaya Ploshchad to Tekhnologichesky Institut stations in the city center. In the confusion, initial reports suggested there were two blasts.
Investigators are seizing items relative to the investigation, questioning witnesses and metro employees and working to confirm the number of dead and injured, Russia's Investigative Committee said in a statement.
The train conductor possibly saved lives, the committee said, because rather than stop the train after the blast, he continued on to the next station, which allowed passengers to evacuate and rescuers to tend to victims.
Photographs show the facade of one of the cars ripped off and passengers running from the Tekhnologichesky Institute station as it filled with smoke. Victims said they helped each other escape the train.
Bodies were seen strewn across a station platform outside the train. Rescuers carried bandaged and bloodied victims out of the station.
'We expected death'
Passengers described the horror
in the aftermath of the blast.
"In the metro car, everyone expected death, if I can say that. After the explosion, everyone expected consequences. Then we were taken out, and people began to help each other, brought others out. Most were covered in blood," a passenger on the train told state-run TASS.
Another passenger at the Sennaya station, Stanislav Listyev, said he felt the explosion and saw smoke coming out of the tunnel.
"I was going down the escalator at Sennaya Square at about half past 2, and at that moment I felt an explosion wave underneath. Everything was filled with smoke, people started panicking. So the trains stopped and almost immediately the evacuation started," he told CNN.
People didn't have 'whole bodies'
Alexey Chirochkin was sitting on a bench in the subway station with his earphones on when he noticed a woman approaching him, he said. As he got up to give her his seat, the woman fell and he grabbed her.
Her face and hands were bloody, and she started crying when he asked if she needed an ambulance, he said.
"Then I take my earphones off, I look around (and I see that) the station is full of smoke," Chirochkin said. "People are running, panic (takes over). But there was no crowd. (People) did not jump over each other, did not push each other ... Some were jumping out of (the metro car's) windows."
"I saw a lot of injured people," he said. "People were crawling while bleeding. They had such a look in their eyes. A girl was yelling, 'Please help my guy!'"
Subway employees ordered people to leave the scene, he said.
Chirochkin recalled helping a man pry open the jammed, bent train doors to pull a victim out of a car and lay him on the platform.
"It is possible that a person that I dragged out was dead," Chirochkin said. "He had a lot of blood on his jacket."
The scene inside the train cars horrified him.
"People there did not have whole bodies ... They were not asking for help. They were not moving," Chirochkin said. "Their eyes were glassy. They were bleeding out. Not a pleasant thing to see."
A spokesman for the National Anti-Terrorism Committee said the blast was caused by an unidentified explosive device in one of the train's cars.
"So far, we say it was an unidentified explosive device as investigators and the Federal Security Service's bomb specialists are to establish the exact cause of this explosion," Andrei Przhezdomsky told state-run Russia 24.
A second device was found at another metro station -- Revolutionary Square -- and was disabled, the committee said in statement. That device, hidden in a fire extinguisher, was larger than the one that went off, according to state media reports quoting law enforcement. It carried about a kilogram of TNT, the reports said.
Authorities closed down the entire metro system, whose five lines carry 2.3 million people a day.
Putin offered his condolences to the victims and said he has been in contact with the security services about the investigation, according to state media.
"The reasons for the explosion are unknown, so it's too early to talk about it. The investigation will show what happened," Putin said, at the beginning of a meeting with Belarussian President Alexander Lukashenko. "Naturally, we always consider all options -- both domestic and criminal, primarily incidents of a terrorist nature."
Kremlin spokesman Dmitry Peskov said Putin had been in St. Petersburg speaking at a media event.
Viktor Ozerov, chairman of the defense committee in the Federation Council, said that the choice of St. Petersburg as a target may have been tied to Putin's visit.
"The choice of the place and the timing of these blasts is not accidental. The president of Russia is in (St. Petersburg). The media forum is taking place there. There are many journalists," Ozerov said.
Medvedev said victims would be provided with "all necessary assistance." He said in a Facebook message: "My most sincere condolences to the families and friends of the victims of the explosion."
Russia was once a hotspot for terror attacks, but the country has experienced relatively few in recent years.
In December 2013, a suicide bombing at a train station in Volgograd killed at least 16 people. The following day, in the same city, a suicide bombing on a trolley bus killed 14 people.
In 2010, two female suicide bombers blew themselves up at two Moscow metro stations, killing 40. They were linked to the Chechen insurgency.
And in 2002, Chechen rebels killed 170 people in a theater hostage situation in the capital, Moscow.
CORRECTION: An earlier version of this story attributed the terrorism motive to the Russian prosecutor general. It was the city's prosecutor general.