About two dozen fighters crossed from the Afghan province of Kunar to launch Saturday's pre-dawn ambush in Bajaur district, Pakistani officials said.
"Militants from across the border ambushed a checkpoint. Two security personnel and an officer embraced martyrdom in the attack," a security official in Bajaur told the AFP news agency.
A senior government official said the rebels were forced to flee after troops retaliated.
No group has yet claimed responsibility but both officials said that Pakistan Taliban fighters were involved in the attack.
"It might be in retaliation for the Pakistan military offensive in North Waziristan," the government official told AFP.
A senior military official in Peshawar, the region's main city, told AFP that the troops were killed when a rocket hit a vehicle near the border post.
Hardline cleric Maulana Fazlullah, the current head of the Pakistan Taliban, is believed to be hiding across the border in Kunar.
Pakistan's armed forces have been waging a massive offensive in North Waziristan, a tribal district south of Bajaur, for the past three-and-a-half weeks to eradicate hideouts fighters have used to launch attacks.