Pakistan and India have agreed to stop trading artillery fire in the disputed Himalayan region of Kashmir after months of routine skirmishes that have killed dozens of soldiers and civilians.

Pakistan’s military said local generals reached the understanding using a special hotline set up to defuse tensions in Kashmir, which is split between Indian and Pakistani zones of control.

The nuclear-armed powers both claim Kashmir in its entirety, and the territorial dispute has ignited two wars between Pakistan and India since they gained independence in 1947.

Both sides “agreed to undertake sincere measures to improve the existing situation, ensuring peace and avoidance of hardships to the civilians along the borders”, the Pakistani military said in a statement.

An Indian man inspects the damage after his home was gutted by firing allegedly from the Pakistan side of the border in Jora farm village, in Ranbir Singh Pura district of Jammu and Kashmir, India
An Indian man inspects the damage after his home was gutted by firing allegedly from the Pakistan side of the border (Channi Anand/AP)

It said that if future violence occurs in the disputed region, “restraint will be exercised and the matter will be resolved through utilisation of existing mechanisms of hotline contacts and border flag meetings at local commander’s level”.

The Indian army confirmed the agreement, saying both sides had pledged to “undertake sincere measures to improve the existing situation to ensure peace and avoidance of hardships to the civilians along the borders”.

The two sides also agreed to fully implement a 2003 ceasefire that has been repeatedly violated.

Tensions have soared in recent weeks as both sides have launched artillery assaults across the Line of Control dividing the region.

Smoke rises from a mortar shell allegedly fired by Pakistani troops at Bainglad village, in Samba sector, about 52km from Jammu, India
Smoke rises from a mortar shell allegedly fired by Pakistani troops (Channi Anand/AP)

Each side has accused the other of starting the hostilities in violation of the 2003 accord.

On the Indian side, the fighting has driven people from villages along the border, and government buildings have been converted into temporary shelters.

Houses have been damaged and dozens of schools in villages along the frontier have been closed, with authorities advising residents to stay indoors.

The shelling has cast a pall over the holy month of Ramadan in the mostly Muslim region.

The shelling typically flares up in the pre-dawn hours, when families are having a meal known as “suhoor” ahead of the daytime fast.

India says 25 civilians and 18 soldiers have been killed this year in more than 800 ceasefire violations initiated by Pakistan.

Pakistan accuses Indian forces of more than 1,050 ceasefire violations this year, resulting in the deaths of 28 civilians and injuries to 117 others.

On Wednesday, Pakistani officials said villagers who fled to safer locations following recent skirmishes have been urged to return to their homes.