Insurgents who attacked a passenger train in Pakistan killed 21 hostages, the military said on Wednesday, while security forces rescued more than 300 others and killed all 50 of the assailants.