It was not immediately clear who planted the device at the small mosque belonging to the minority Shiite Muslim community in the town of Dera Ismail Khan, which has a history of sectarian violence.
"Four people were killed and two others were injured when a timed explosive device went off at a mosque," district police chief Abdul Ghaffar Qaiserani told AFP.
The official said that people were coming out of the mosque after prayer when the blast went off.
The police found a number of battery cells from the rubble which indicate the bomb, planted near the main entrance, was on a timer, another police official said.
Witnesses said that the blast demolished some parts of the mosque and nearby markets were shut down immediately after the incident to curb possible protests.
Qaiserani declined to say if it was a sectarian attack, but similar bombings and gun attacks have taken place between the supporters of Shiite and Sunni extremist groups active in Dera Ismail Khan, which borders volatile tribal areas.
Last month gunmen shot dead five people including three Shiites and a policeman on the outskirts of the town.
Shiites account for about 20 percent of Pakistan's 160 million, Sunni-dominated population. The groups usually coexist peacefully but outbreaks of sectarian violence have claimed more than 4,000 lives across the country since the late 1980s.