Two policemen were critically injured in the shootout which took place in the early hours.
The Counter Terrorism Department of Punjab Police said it received intelligence reports that some terrorists hiding in Sheikhupura, around 50 km from Lahore, were planning to attack law enforcement personnel and important buildings in Sheikhupura and Lahore.
"A CTD team along with police commandos raided the hideout in Narang Mandi village in early hours of Thursday and warned the terrorists to surrender. Instead they opened fire on the police team. In the cross-fire eight terrorists were killed and three to four of their accomplices managed to escape," the CTD said.
The CTD said the dead terrorists belonged to Jammat-ul- Ahrar. The security officials seized 3 kg explosives, two kalashnikov rifles, pistols and suicide vests from the spot.
Jammat-ul-Ahrar has been involved in a series of bombings in Punjab. It claimed responsibility for this February's attack on policemen in Lahore that killed 15 people including six cops.