Media playback is unsupported on your device Media caption Footage appears to show wreckage from a downed Indian jet

Pakistan says it has shot down two Indian military jets and captured a pilot in a major escalation between the nuclear powers over Kashmir.

India said it had lost one MiG-21 fighter and demanded the immediate and safe return of its pilot.

Pakistani PM Imran Khan said the two sides could not afford a miscalculation with the weapons they had.

India and Pakistan - both nuclear-armed states - claim all of Kashmir, but control only parts of it.

They have fought three wars since independence from Britain and partition in 1947. All but one were over Kashmir.

The aerial attacks across the Line of Control (LoC) dividing Indian and Pakistani territory are the first since a war in 1971.

They follow a militant attack in Kashmir which killed at least 40 Indian troops - the deadliest to take place during a three-decade insurgency against Indian rule in Kashmir. A Pakistan-based group said it carried out the attack.

The BBC's Soutik Biswas, in Delhi, says the challenge for India and Pakistan now is to contain the latest escalation before things get completely out of control.

What do we know about the situation?

Pakistan's military spokesman said that Pakistan fighter jets had carried out "strikes" - exactly what they did remains unclear - in Indian-administered Kashmir on Wednesday.

Two Indian air force jets then responded, crossing the de facto border that divides Kashmir. "Our jets were ready and we shot both of them down," Maj Gen Asif Ghafoor said.

He said that one Indian pilot was in the custody of the Pakistani army. Officials had previously said two pilots had been captured and one had been taken to hospital.

No explanation has been given as to why the numbers have changed.

Maj Gen Ghafoor said the captured Indian pilot, Wing Commander Abhinandan, was being "treated as per norms of military ethics".

Earlier Pakistan's information ministry published but subsequently deleted a video showing the pilot - blindfolded and with blood on his face - identifying himself to soldiers.

Image copyright Pakistan Information Ministry Image caption Pakistan's information ministry tweeted a video purporting to show a captured Indian pilot

Another video circulating on social media appeared to show the pilot being beaten by residents in Pakistan-controlled Kashmir before the arrival of Pakistani soldiers.

Pakistan's information ministry also tweeted what it said was footage of one of the downed Indian jets.

In India, Ministry of External Affairs spokesman Raveesh Kumar acknowledged the loss of a jet and its pilot.

He also said that an Indian plane had shot down a Pakistani fighter jet, and Indian ground forces observed it falling on the Pakistani side of the LoC. Pakistan denied any of its jets had been hit.

India's foreign ministry later issued a statement demanding the release of its fighter pilot and condemning the images shared by Pakistan of Wing Commander Abhinandan, describing them as a "vulgar display of an injured personnel".

How are India and Pakistan reacting?

In a televised address, Prime Minister Khan offered India talks over terrorism and warned against further escalation.

"If we let it happen, it will remain neither in my nor Narendra Modi's control," he said.

"Our action is just to let them know that just like they intruded into our territory, we are also capable of going into their territory," he added.

Mr Modi has yet to comment but was meeting top security and intelligence officials to discuss the situation, reports in India said.

Indian Foreign Minister Sushma Swaraj said her country would act "with responsibility and restraint".

"India does not wish to see further escalation of the situation," she said, speaking from a meeting with Russian and Chinese foreign ministers in China.

What about the earlier air strikes?

Pakistan's assertion that it had shot down two Indian aircraft came shortly after Islamabad said its warplanes had struck targets in Indian territory.

Indian authorities said the Pakistani jets had been forced to withdraw.

Pakistan's military spokesman Maj Gen Ghafoor said jets had "engaged" six targets in Indian territory but then carried out air strikes on "open ground".

"We don't want to go on the path of war," he said.

India said Tuesday's air strikes on Balakot in north-western Pakistan killed a large number of militants, but Pakistan said there had been no casualties.

The US, EU and China have all called for restraint.

'These are uncharted waters'

By Soutik Biswas, BBC News, Delhi

The challenge for India and Pakistan now is to contain the escalation before things get completely out of control.

It is almost unprecedented for two nuclear-armed countries to carry out air strikes into each other's territories.

"We are in uncharted waters," Husain Haqqani, the former Pakistani ambassador to the US and adviser to three Pakistani prime ministers, told me late on Tuesday.

An Indian defence analyst believes Indian security forces will now have to be prepared for a "full spectrum of conflict".

However Daniel Markey from Johns Hopkins University in the US says we are "several steps away" from nuclear escalation.

A further escalation, he believes, will happen if Pakistan's "next step were to raise the stakes by hitting Indian civilian targets".

That is highly unlikely.

What else is happening?

Pakistan has closed its entire airspace, its civil aviation authority said. Nine airports in northern India were temporarily closed but have now reopened, reports in India say.

The flight monitoring group Flight Radar says international flights have been avoiding the area.

Later on Wednesday Thai Airways, which said it was directly affected by the closure of airspace, cancelled all Europe-bound flights and said it had requested permission to use other routes.

Other airlines such as British Airways, Air India, Jet Airways, Qatar Airways and Singapore Airlines re-routed flights.

Both Indian and Pakistani troops have been shelling across the LoC. Four Pakistani civilians were killed and 10 others were injured in cross-border shelling on Tuesday.

On the Indian side, five soldiers were also injured in the firing, officials told the BBC. Schools in at least two districts along the LoC - Rajouri and Poonch - have been closed.

People living along the de facto border have been asked to leave their homes.

In a separate incident on Wednesday morning, six members of the Indian Air Force were killed when their helicopter crashed in Indian-administered Kashmir. India's defence ministry said the incident occurred during a routine operation and was an accident.

Timeline of India-Pakistan tensions

Media playback is unsupported on your device Media caption In December Yogita Limaye examined why there had been a rise in violence in Kashmir

October 1947: First war between India and Pakistan over Kashmir just two months after they become independent nations.

August 1965: The neighbours fight another brief war over Kashmir.

December 1971: India supports East Pakistan's bid to become independent. The Indian air force conducts bombing raids inside Pakistan. The war ends with the creation of Bangladesh.

May 1999: Pakistani soldiers and militants occupy Indian military posts in Kargil mountains. India launches air and ground strikes and the intruders are pushed back.

October 2001: A devastating attack on the state assembly in Indian-administered Kashmir kills 38. Two months later, an attack on the Indian parliament in Delhi leaves 14 dead.

November 2008: Co-ordinated attacks on Mumbai's main railway station, luxury hotels and a Jewish cultural centre kill 166 people. India blames Pakistan-based group Lashkar-e-Taiba.

January 2016: Four-day attack on Indian air base in Pathankot leaves seven Indian soldiers and six militants dead.

18 September 2016: Attack on army base in Uri in Indian-administered Kashmir kills 19 soldiers.

30 September 2016: India says it carried "surgical strikes" on militants in Pakistani Kashmir. Islamabad denies strikes took place.