Image copyright AP Image caption Afghan security forces personnel could be seen on the roof of the main prison building after the attack

Taliban militants have stormed a jail outside the central Afghan city of Ghazni, killing at least four policemen and freeing more than 350 prisoners.

The deputy governor of Ghazni province Mohammad Ali Ahmadi said one militant blew himself up at the prison gates, allowing others to force open cells.

The attackers were well-organised and wearing uniforms, he said.

It is the third time since 2008 that hundreds of Taliban inmates have escaped from an Afghan prison.

Both Taliban spokesman Zabihullah Mujahid and the deputy governor confirmed that three of the attackers had been killed.

The deputy governor said seven police officers were injured and only 80 prisoners were left inside the prison.

Both Mr Ahmadi and the Taliban said the escapees included a number of local Taliban commanders, as well as many other fighters.

Of those freed, the interior ministry said 148 had been jailed for attacks on security forces, while 207 had been convicted for other crimes. Only three prisoners had been recaptured so far.

Mr Ahmadi did not reject the possibility the attackers had had help from inside the jail.

He told the BBC's Mahfouz Zubaide in Kabul that one of the attackers who had been killed was a former inmate who had been released.

Analysis, Inayatulhaq Yasini, BBC Afghan

The massive overnight jailbreak in Afghanistan's volatile Ghazni province is yet another reminder of the many challenges faced by the Afghan government.

Monday's prison break has happened at a sensitive time for the government, which will complete its first year in office in a week's time, amid questions over its ability to improve security and the economy.

The Taliban will use the attack as a way to boost morale for its fighters, who are divided over succession to founder Mullah Mohammad Omar.

It will also add to concerns among ordinary Afghans about the state's hold on security.

Image copyright Reuters Image caption Three of the insurgents died during the attack

Image copyright AP Image caption The Afghan army stood guard in front of the main prison building after the attack

Local officials told the BBC that as the attackers had made their way through the jail, the prisoners did not initially realise the attackers were Taliban because of their uniforms.

The jail is about 5km (three miles) outside Ghazni city, about 120km from the capital Kabul.

In 2011, nearly 500 prisoners - including many Taliban insurgents - escaped from a jail in Kandahar city, after a tunnel hundreds of metres long was dug from the outside.

Afghan jail breaks