PESHAWAR, Pakistan — A bomb exploded inside a vehicle at a Pakistani military compound in the country’s northwest on Sunday, killing at least 20 members of a paramilitary unit and wounding 30 more, a security official said.

A unit of the Frontier Corps was moving from the compound in Bannu to Razmak in the volatile North Waziristan tribal region when a bomb planted in their vehicle exploded, said the official, who insisted on anonymity because he was not authorized to speak to the news media.

The official said a road curfew was in place on Sunday to secure the transportation of troops to and from the tribal region, where military convoys have been hit by roadside bombings and ambushes.

The troops, the official said, were to be ferried in an unmarked vehicle. “The vehicle was rented from a local bazaar. We have a shortage of vehicles,” the official said. “Most probably, the bomb was already planted inside the vehicle. The driver of the vehicle has also been killed.”