Police on a tip-off conducted operation on which the terrorists opened fire and injured one official.
Explosive material has also been recovered from the killed terrorists.
Police has identified them as Rehmatullah who belong to banned Tehreek-i-Taliban Swati group and Khalid alias Khudai from Lyari gang war.
Rehmatullah was involved in more than 15 crime incidents including the attacks on police and Rangers whereas Khalid killed 42 people, Senior Superintendant Police (SSP) Chaudhry Aslam, Anti Car Lifting Cell (ACLC) SSP Irfan Bahadur and four other policemen.
Karachi, a metropolis of 20 million that hosts the stock exchange and central bank, is beset by armed violence, and many of its sprawling slums are no-go areas for outsiders.
Two years ago, the military, with help from police, paramilitary Rangers and intelligence agencies, unleashed a campaign against armed gangs and suspected militants in the city.
The operation, which escalated in March this year, is officially aimed at eradicating criminals and militants.