The raid prompted fears of the kind of prolonged siege which followed similar attacks on key installations in recent years.
Army spokesman Asim Saleem Bajwa said in a statement: "All passengers in planes have been evacuated and three terrorists killed."
A senior intelligence official at the scene, who requested anonymity, said the total number of militants killed was six and that some were found wearing a light blue uniform.
"One of them blew up when he was shot," the official said, indicating the assailant was wearing a suicide vest.
The attackers appeared to have entered from at least two sides of the airport; the hajj terminal and the engineering section close to an old terminal no longer used for passengers.
The precise number of attackers was unclear. Officials earlier put the figure at around half a dozen, though later the figure was believed to be higher.
The attackers were armed with machine guns and grenades.
The army, the airport security force, police and paramilitary forces have all been deployed at the scene, where gunfire was intermittent.
A paramilitary ranger engaged in the operation said the militants who had entered through the engineering section of Pakistan International Airlines (PIA) gunned down security personnel first.
An AFP reporter at the airport said there had been two "huge" blasts indicating more suicide bombers had detonated their explosives.
Broken glass and spent gun magazines littered the engineering section where the first exchange of gunfire took place as smoke from grenade attacks began to die down.
- 'I saw the terrorists firing' -
Eye-witness Sarmad Hussain, a PIA employee, told AFP: "I heard fierce firing and then saw the terrorists firing at security forces. I don't know a lot more than that. Thank God I am alive, this is very scary."
A police official who did not wish to be identified said an unexploded rocket-propelled grenade had been recovered.
The director of the city's main Jinnah Hospital, doctor Seemi Jamali told AFP six dead bodies had been brought in and the hospital had declared an emergency.
The dead comprised security personnel and two civilians, along with fourteen others wounded.
A spokesman for PIA, Mashud Tajwar added that two domestic flights bound for Karachi had been diverted to nearby airports.
There has so far been no claim of responsibility for Sunday night's incident but similar raids in the past have been claimed by Taliban militants who rose up against the Pakistani state in 2007 in an insurgency that has claimed thousands of lives.
Taliban gunmen attacked the Mehran naval base in 2011, which is three kilometres from the airport, destroying two US-made Orion aircraft and killing 10 personnel in a 17-hour siege.Taliban and other militants in uniform carried out a similar raid at Pakistan's military headquarters in the garrison city of Rawalpindi in 2009, leaving 23 dead including 11 troops and three hostages.
Prime Minister Nawaz Sharif's government began negotiations with the umbrella militant group Tehreek-e-Taliban Pakistan (TTP) in February, with a ceasefire beginning March 1 but breaking down a month later.
The TTP emerged in response to a raid on a radical mosque in Islamabad, but Islamist violence in the country began to surge in 2004 following the army's deployment in the volatile tribal areas.
-- Attack on Shiite pilgrims --
In a separate attack in southwest Baluchistan province at least 23 people including several Shiite pilgrims were killed in a gun and suicide assault on the restive Pakistan-Iran border late Sunday.
The attack came when a bus carrying Pakistani pilgrims returning from a visit to holy Muslim sites in Iran stopped at a restaurant in the Pakistani town of Taftan, around 700 kilometres (430 miles) southwest of the provincial capital Quetta.
Provincial home secretary Akbar Durrani said four suicide bombers attacked two restaurants full of pilgrims.
One suicide bomber was shot dead trying to enter one of the restaurants while the other three managed to enter a second restaurant and blow themselves up.
As well as the Taliban threat, Pakistan is facing a rising tide of sectarian bloodshed mainly targeting minority Shiite Muslims.