An unknown number of passengers were abducted from the train, considered the safest way to get between the cities.
Seven passengers have died after gunmen attacked a busy train between Nigeria's capital, Abuja, and Kaduna city, hospital sources have told the BBC.
The gang mined the track forcing the train, carrying 970 passengers, to a stop on Monday evening.
Gunmen subsequently surrounded the carriages and opened fire, one passenger told the BBC.
An unknown number of passengers were abducted from the train, considered the safest way to get between the cities.
Kidnapping for ransom has become commonplace across Nigeria.
The Abuja-Kaduna highway is one of the most dangerous roads in the country as kidnappers have been known to have ambushed vehicles at several points along the expressway.
Over the last few years this has pushed many to avoid the 150km (93-mile) journey by road instead opting for the rail link, which opened in 2016. It is more expensive but considered safer as the trains have armed guards on board.
This is the second time the rail line between the cities has been targeted in the last six months, but is by far the most serious, says the BBC's Chris Ewokor in Abuja.
According to the BBC Hausa service, 22 people, who were injured in the attack on Monday evening, are being treated at a military hospital in Kaduna.
One woman working as a hospital volunteer in Kaduna told the BBC's Focus on Africa radio programme that the first-hand accounts she had heard were "scary" and "traumatising".
A railway worker told her he had manged to escape from the kidnappers by running away as they took him and "25 people into the forest" on foot.
Another person recounted that when she was shot "the bullet went through her knee" and that she had been saved by the military.
A senior security source told the AFP news agency that military personnel rushed to the scene.
"The attack has been repelled by the troops who deployed in time. The terrorists fled when the soldiers arrived. The train is bulletproof, this saved the passengers who lay still on the floor."
The Nigerian Railway Corporation (NRC) has suspended operations along the route.
The governor of Kaduna state has also condemned the attack, describing it as a "terrorist" incident and sent his condolences to the families of the victims.
The rail line is a gateway for millions of people in north-western states who want to travel to Abuja and further south.
The authorities in Kaduna state say they are liaising with the NRC to find out where all the passengers are and who exactly is missing.
Armed gangs carrying out killings and kidnappings for ransom have continued to unleash violence, especially in northern Nigeria despite military bombardments of their hideouts.
Just last Saturday, they attacked Kaduna's international airport.