The incident occurred in Jhelum district when a villager alerted police about a terrorist digging a railway track.
The terrorist was allegedly targeting the Rawalpindi to Lahore Pakistan Express and tried to plant explosives on railway tracks near Grand Trunk Road when a villager reported the suspicious individual, police official Zulfiqar Virk said.
On seeing the police, the suspect tried to flee but he was surrounded by police and asked to surrender. However, he blew himself up, Virk said.
He said timely alert by the villager saved many precious lives as the attempt to plant the bomb was foiled.
Pakistan railway had been targeted several times by the militants in recent months.