Pakistani security forces have exchanged gunfire with hundreds of separatist militants as they sought to free about 300 hostages aboard a train in the country’s rugged southwest, officials said.

Security forces were being cautious as officials said the hostages were surrounded by militants wearing vests loaded with explosives.

At least 27 militants have been killed and security forces rescued more than 150 of the 450 people who were on the train when it was hijacked on Tuesday as it entered a tunnel in Bolan, a district in restive Balochistan province.

Rescued passengers arrived in Quetta (AP)

The Baloch Liberation Army group has claimed responsibility for the attack, saying it was open to negotiations to swap prisoners.

There has been no response or any indication from the government to the offer from the insurgents.

Authorities said the rescued included women and children, while an undisclosed number of security personnel have been killed, according to three security officials who spoke on condition of anonymity as they were not authorised to speak to media.

Officials said the attackers blew up the railway track in volatile south-western Balochistan province and exchanged fire with security guards on board the train.

The train was travelling from the provincial capital of Quetta to the northern city of Peshawar when it came under attack in Bolan district, government spokesman Shahid Rind said, calling it “an act of terrorism”.

More than 150 people were rescued (AP)

UN secretary-general Antonio Guterres strongly condemned the attack and called for the immediate release of the hostages, UN spokesman Stephane Dujarric said.

Officials at Pakistan Railways said the Jafar Express train was carrying an estimated 500 passengers, including women and children.

Trains in Balochistan typically have security personnel on board. Separatists have previously carried out deadly attacks on trains in the region.

In November, a separatist group carried out a suicide bombing at a railway station in Quetta which killed 26 people.

Oil and mineral-rich Balochistan is Pakistan’s largest and least populated province. It is a hub for the country’s ethnic Baloch minority, whose members say they face discrimination and exploitation by the central government.