The train, which had about 400 passengers, was trapped in a tunnel and the driver was badly wounded, local authorities, police and railway officials said, without confirming the Baloch Liberation Army's account of hostages.
Security forces said an explosion had been heard around the tunnel and that they were exchanging fire with the militants in a mountainous area.
The BLA, which seeks independence for Balochistan province bordering both Afghanistan and Iran, said it had killed 20 soldiers and shot down a drone.
There was no confirmation of that from Pakistani authorities.
The group said it had taken 182 hostages from the train, including Pakistan army members and other security officials travelling on leave.
"Civilian passengers, particularly women, children, the elderly, and Baloch citizens, have been released safely and given a secure route," it said in a statement emailed to journalists and posted on Telegram.
"The BLA further warns that if military intervention continues, all hostages will be executed."
The Jaffar Express had been on its way from Quetta in Pakistan's southwestern Balochistan province to Peshawar in Khyber Pakhtunkhwa when it was fired on.
Pakistan's interior minister Mohsin Naqvi condemned the attack and said the government would not make any concessions to "beasts who fire on innocent passengers".
The Balochistan government has imposed emergency measures to deal with the situation, spokesman Shahid Rind said.
The BLA is the biggest of several ethnic groups battling the government for decades, saying it unfairly exploits Balochistan's rich gas and mineral resources.
The conflict has featured frequent attacks against the government, army and Chinese interests in the region.