Fighting between soldiers and militants and a bomb attack on a train have killed at least 42 people in Pakistan, officials said Wednesday. Most of the deaths occurred overnight when suspected Taliban rebels attacked an army post in the Sarang Baba Zairat area of the Badar region of South Waziristan, in Pakistan's restive north-western tribal region. "We killed 18 militants but also lost nine soldiers in the fight," a security official was quoted as saying by dpa. He said most of the militants were killed in the army counter-offensive in the mountainous region. Three soldiers and nine militants were killed in other clashes late Tuesday in the Bajaur district of north-west Pakistan, a security official said. Separately, three people were killed while 27 others injured when a train hit a bomb planted on railway tracks in Tul town in Jacobabad district in the southern province of Sindh. General manager of Pakistan Railways, Junaid Qureshi, told dpa that two coaches of the train were derailed after the explosion. Around 400 passengers were on board. Nobody took responsibility for the attack on the train going from the southern port city of Karachi to Peshawar, the capital of Khyber-Pakhtunkhwa.