Media playback is unsupported on your device Media caption The BBC's Aleem Maqbool says the policemen may have unwittingly let the gunmen in

Militants have shot dead at least nine Pakistani trainee policemen after attacking their housing compound in the eastern city of Lahore.

Reports say up to 10 masked gunmen arrived on motorcycles and stormed a rented building in the Rasool Park area where the trainees were staying.

All those killed were from the north-western province of Khyber Pakhtunkhwa and training to be prison police.

The Pakistani Taliban said they carried out the attack.

"We were looking for [the police] for a long time as their attitude with our people in jails is very inhuman and insulting," Taliban spokesman Ehsnanullah Ehsan is quoted as saying.

He said that they had been targeted for not treating Taliban detainees well.

A rescue official quoting witnesses told the BBC that the attackers first shot and injured a security guard and then climbed to the first floor of the building where they opened fire on the policemen there. They then escaped from the scene, the official said.

This is the second such attack this week in central Punjab province, of which Lahore is the capital.

On Monday, Taliban gunmen killed seven security personnel at a campsite in Gujrat district of Punjab province.

Most recent assaults have taken place in the restive north-west and correspondents say Punjab has been largely peaceful over the past year.

In March 2009, the Taliban launched a major attack on Lahore's police training academy, leaving at least 18 people dead.