Gunmen attacked one of Pakistan's biggest airports on Sunday and at least 23 people were killed, including all 10 of the attackers, media reported.

The attack on Jinnah International Airport in Karachi, Pakistan's sprawling commercial hub of 18 million people, took place as Prime Minister Nawaz Sharif's government tries to engage Pakistani Taliban militants in negotiations to end years of fighting.

Gun battles went on for several hours and television pictures showed fire raging at the airport as ambulances ferried casualties away, but by dawn on Monday, the army said the airport had been secured.

"(The attackers) were confined to two areas and eliminated," the Dawn newspaper cited military spokesman Major-General Asim Bajwa as saying.

There was no immediate claim of responsibility, but Pakistani Taliban militants, allied with but separate from the Afghan Taliban, are battling to overthrow the Pakistani state and impose their hardline vision of Islamist rule.

Earlier, officials said all flights had been diverted.

Peace talks between the government and the Pakistani Taliban have failed in recent months, dampening hopes of reaching a negotiated settlement with the insurgency, which continues attacks against government and security targets.