The train derailed near Bioce, a village about nine miles northeast of Podgorica, shortly after 4 p.m., as it emerged from a tunnel above the Moraca River, police said.
Interior Minister Jusuf Kalomperovic said initial reports indicated the train's brakes may have failed.
Police, medical workers and volunteers pulled bodies from the 328-foot ravine.
An Associated Press reporter saw 10 bodies on the side of the road above the ravine and dozens of injured carried on stretchers.
At least 106 injured passengers, including 10 children, were taken to the main hospital in Podgorica, said its director, Miodrag Djurovic. He appealed for blood donors.
Investigative judge Zoran Radovic told the AP the entire train fell into the ravine and that it was carrying many schoolchildren home from a skiing holiday in the north.
Victims cried for help from the ravine, where four train cars lay smashed. Darkness in the densely forested area was hampering rescue efforts.
"It was horrible, I saw many dead and wounded around me," said one passenger from Hungary, Karman Chofu.
The train was en route from the northeastern town of Bijelo Polje to the Montenegrin coastal city of Bar when it derailed near Podgorica.
"I had fallen asleep when a loud noise woke me," said Stanislava Bukovic, 60, one of the injured passengers, as she was carried away on a stretcher.
"Then I felt something hit my head and lost consciousness," she added. "The next thing I knew I was on this stretcher."
Montenegrin President Filip Vujanovic visited the scene and called it a "catastrophe."