Taliban fighters disguised as police and armed with bombs and grenades have freed 250 prisoners from a jail in Pakistan.

The overnight attack raises serious questions over the new government's ability to combat militancy.

Fighting continued into the early hours of this morning, with explosions and machine gunfire being heard in the city of Dera Ismail Khan.

The freed prisoners included dozens of top militants.

Gunmen launched the attack by blowing up the electricity line to the prison and detonating heavy explosions that breached the outer walls.

They then fought their way inside using rocket-propelled grenades and machine guns, and calling the names of Taliban prisoners through loud speakers.

Security forces said they had imposed a curfew on the city and the gunbattle was over by dawn.

Security forces and bomb disposal squads conducted searches amid ruined walls strewn with bullet holes.

The attacks came the day politicians are due to choose a new president in a largely ceremonial vote, and two days before a major Shia festival which security officials have warned could be attacked.

Another security official said provincial authorities received warnings of the impending attack two weeks ago.

He said phone intercepts indicated the gunmen had been planning a jail break and interrogations of captured fighters confirmed it.

Security officials had alerted the provincial governor of the threat based on the intercepts.

The Pakistani Taliban said they had sent a squad of 100 fighters and seven suicide bombers on a mission to free some of their top leaders, and they said they released 250 prisoners.

Mushtaq Jadoon, the town's civil commissioner, said the 253 escaped prisoners included 30 top militants and six people on death row.

Those who escaped are believed to have been whisked away to the lawless tribal areas of South and North Waziristan.

The heavily guarded jail houses around 5,000 prisoners.

A senior Taliban official told Reuters separately the attack on the prison was masterminded by Adnan Rashid, a Taliban commander who was himself freed when his prison in the northern town of Bannu was overran by militants last year.

After that attack, militants told Reuters they had been helped by insiders in the security services.

An inquiry later found there were far fewer guards on duty than there should have been and those who were there lacked sufficient ammunition.