An operation to secure a militant-hit Indian air base near the Pakistan border ended on Saturday with at least four suspected Islamist gunmen killed, police said, after an assault that threatens to undermine the two countries' fragile peace process.

Special commandos secured the Pathankot air force base 14 hours after it was infiltrated by gunmen wearing army uniforms suspected to be from the Pakistan-based Jaish-e-Mohammed Islamist group, officials said.

The attack comes a week after Prime Minister Narendra Modi paid a surprise visit to Pakistan, the first by an Indian premier in 11 years, and threatens to derail talks between the nuclear-armed rivals.

"We have recovered four dead bodies and are searching for more. Our men are sanitising the area," H. S. Dhillon, a senior police chief for the Punjab region told AFP.

An army official confirmed the operation had ended and forces were checking the area for residual explosives.

Officials did not confirm the state broadcaster's reports that three security personnel had died at the base - a rare targeting of an Indian military installation outside disputed Kashmir.

Home Minister Rajnath Singh tweeted his congratulations to the army on "successfully neutralising" the terrorists.

"We want peace but if terrorists carry out attacks on Indian soil we will give them a befitting reply," he said earlier in the day.

Pakistan condemned the attack on Saturday afternoon, describing it as a "terrorist incident".

"Building on the goodwill created during the recent high-level contacts between the two countries, Pakistan remains committed to partner with India... to completely eradicate the menace of terrorism afflicting our region," Islamabad's foreign ministry spokesman said.

Pakistan opposition senator Sherry Rehman tweeted:

"#Pathankot is about derailing peace. Don't let terror define our agenda. Pak-India talks must go on."

Strategic base  

The Pathankot air base houses dozens of fighter jets and is important for its strategic location about 50 kilometres from the Pakistan border.

"They are from Jaish, Jaish has claimed responsibility," Indian army Lieutenant General Satish Dua told reporters. AFP was not able to verify the alleged claim of responsibility.

Jaish-e-Mohammed, which is banned in Pakistan, fights against Indian rule in the divided Himalayan region of Kashmir, where a separatist conflict has claimed up to 100,000 lives.

While Punjab has largely been spared such violence, however, it has not been immune.

In July, three gunmen said to be Pakistan-based Lashkar-e-Taiba militants killed seven people, including four policemen, in an attack in the Sikh-majority state.

Modi's December 25 visit to Lahore to meet his Pakistani counterpart Nawaz Sharif indicated a potential thaw in tensions between the historical foes, and the foreign secretaries of both countries are to meet in Islamabad this month.

But his friendly outreach prompted critics to warn of retaliation by militants.

"Our prime minister visited and after that the terrorists came here. They want friendship with Pakistan but look what they are doing to us," said Ashok Kumar, 52, a shopkeeper in Pathankot.

A protest broke out on the road leading to Pathankot base in the early afternoon on Saturday as angry residents burned effigies apparently intended to resemble Pakistani militants, an AFP journalist at the scene said.

Fragile peace  

Sameer Patil, a security analyst at the Gateway House think-tank in Mumbai, said Saturday's attack was likely to be a cross-border strike possibly carried out in retaliation for the visit.

"There is substantial first evidence of Jaish-e-Mohammed and Lashkar-e-Taiba militants trying to sabotage the peace process," he told AFP.

India blamed Jaish-e-Mohammed for a December 2001 attack on the Indian parliament that killed 11 people, led to a massive military build-up at the border and brought the two countries almost to the brink of war.

New Delhi later suspended all talks with Islamabad after Islamist gunmen attacked the city of Mumbai in November 2008, killing 166 people in attacks planned from Pakistan.

The two countries agreed to resume a peace process in 2011 but tensions spiked again in recent years, with cross-border shelling in Kashmir claiming dozens of lives since 2014.

Authorities had put Punjab on high alert on Friday after five gunmen in army fatigues hijacked a car driven by a senior police officer, which was later found abandoned on a highway connecting Pathankot to Kashmir.

It was not clear if there was any link with Saturday's attack.