Suspected militants infiltrated an Indian air force base near the border with Pakistan on Saturday and exchanged fire with security forces for hours, leaving at least four gunmen and two Indian troops dead, officials and news reports said.

Although it was unclear who staged the attack, it was being seen as a possible attempt to undo recent progress made in relations between rivals India and Pakistan, coming just a week after the first visit to Pakistan in 12 years by an Indian prime minister.

The attack at the Pathankot air force base began a couple of hours before dawn, and by late morning it appeared that the violence had ended with the killing of the gunmen by Indian forces. But two hours later, more gunfire erupted and an air force helicopter was seen firing at an area of the base, a major installation located about 430 kilometres north of New Delhi.

Air force spokeswoman Rochelle D'Silva said Saturday night that troops were combing the entire base to fully secure it. She said the combing operation was expected to continue through the night, and that the full number of casualties would be clear once the base was completely secured.

By 9 p.m. IST (10:30 a.m. ET), no gunfire had been heard around the base for more than three hours.

The defence ministry said there had been intelligence reports about a likely terror attack on military installations in Pathankot, and that the air force had been prepared to thwart any attackers.

"Due to the effective preparation and co-ordinated efforts by all the security agencies a group of terrorists were detected by the aerial surveillance platforms as soon as they entered the Air Force Station at Pathankot," the ministry said in a statement.

Despite the intelligence on a possible attack, at least two air force troops were killed in the gun battle, the Press Trust of India news agency reported. PTI, citing police, also said at least four gunmen had been killed.

The attack began at around 3 a.m., when a group of gunmen entered the section of the base where the living quarters are located, the defence ministry said. The attackers, however, were unable to penetrate the area where fighter helicopters and other military equipment are kept, it said.

Kashmir region claimed by both Pakistan and India

Police said they suspected the gunmen were militants, and were investigating whether they had come from the Indian portion of Kashmir or from Pakistan. The Himalayan region of Kashmir is divided between India and Pakistan, but is claimed in its entirety by both.

Rebels routinely stage attacks in Indian-held Kashmir, where they've been fighting since 1989 for an independent Kashmir or its merger with Pakistan.


Indian security personnel stand guard outside the Indian Air Force base at Pathankot in Punjab, India, on Jan. 2, 2016. (Mukesh Gupta/Reuters)

India accuses Pakistan of arming and training Kashmir's insurgents, a charge Islamabad denies, and the attack was viewed by many in India as an attempt to unravel recent progress in the country's relationship with its rival.

The violence came just a week after Indian Prime Minister Narendra Modi made an unannounced visit to Pakistan to meet with his Pakistani counterpart, Nawaz Sharif. The visit was seen as a potential sign of thawing relations between the two nuclear-armed neighbours. The two leaders also held an unscheduled meeting at the Paris climate change talks last month.

Ahead of Modi's visit to Pakistan, the national security advisers of both countries had met in Thailand. The foreign secretaries of both nations are scheduled to meet in Islamabad later this month.

In the past, the contentious issue of Kashmir has halted talks between the rivals.

"These kinds of attacks are nothing new and have generally been the outcome of the dispute of India and Pakistan over Kashmir," said Noor Ahmed Baba, a political scientist at Central University in Indian Kashmir's capital, Srinagar.

Baba said that there were elements in both countries that would like to see the peace process fizzle out, and that all sides must "exhibit political maturity and sagacity to defeat the vested interests."

Modi, at a speech in the southern city of Mysore, said: "I congratulate the nation's security forces for turning the intentions of our country's enemies into dust. They didn't let them succeed. And I salute the martyrdom of the soldiers who sacrificed their lives."

Attack condemned

Pathankot, in Punjab state, is on the highway that connects India's insurgency-wracked Jammu and Kashmir state with the rest of the country. It's also very close to India's border with Pakistan.

Pakistan's foreign ministry condemned the attack. "Building on the goodwill created during the recent high level contacts between the two countries, Pakistan remains committed to partner with India as well as other countries in the region to completely eradicate the menace of terrorism afflicting our region," it said in a statement.

Indian Home Minister Rajnath Singh told reporters that India wants peace with Pakistan, but "if there is any kind of terror attack on India, we will give it a fitting reply."

India's defence minister, national security adviser and the chiefs of the army, navy and air force met Saturday to discuss the situation.

In July, gunmen staged a similar attack at a police station and a moving bus near Gurdaspur, a border town in India's Punjab state. The three attackers then killed four policemen and three civilians before being shot dead by security forces.