Pakistani premier Nawaz Sharif will attend Indian prime minister-elect Narendra Modi's inauguration on Monday, his office said, in an unprecedented diplomatic move aimed at mending strained ties between the nuclear-armed rivals.

The Pakistani PM's attendance will be a first in the history of the South Asian neighbours, which have fought three wars since independence in 1947 and remain bitterly divided over the disputed region of Kashmir.

Like all other heads of government from the South Asian Association for Regional Cooperation (SAARC) which includes Pakistan, Sharif had also been formally invited by India this week.

"Prime Minister Nawaz Sharif has decided to visit India and attend the swearing-in of... Modi," his spokesman told AFP on Saturday.

Pakistan's foreign ministry said Sharif will hold bilateral talks with Modi on the morning of May 27 and will also meet Indian President Pranab Mukherjee.

Modi will take the oath as prime minister on Monday, 10 days after his right-wing Hindu nationalist Bharatiya Janata Party (BJP) scored a landslide victory, securing the first majority by a single party in 30 years.

"It's very good news that Nawaz Sharif has accepted Mr Modi's invitation," BJP spokesman Prakash Javadekar told reporters in New Delhi. "It will mark a new beginning in our ties."

Sharif, who is himself a centre-right leader, has hailed Modi's "impressive victory" and many diplomats hope the two men can thaw ties between the neighbours.

Sharif has cited his working relationship with Atal Bihari Vajpayee, India's last prime minister with the right-wing Bharatiya Janata Party (BJP) as a reason for optimism, according to diplomatic sources.

It was during Sharif's second term in 1999 that Vajpayee rode a bus to Lahore to sign a peace accord, raising the prospect for normalisation between the two neighbours.

Three months later, the countries embarked on the Kargil conflict in the Himalayan region of Kashmir -- though Sharif has blamed his then-army chief General Pervez Musharraf who went on to overthrow him in a coup, for provoking the fighting without his knowledge.

"Vajpayee had said you can choose your friends but you can't choose your neighbours. Mr Modi is following just that" principle by extending an invitation to Sharif, Javadekar said.

'Modi-Sharif handshake'

Talat Masood, a political analyst and retired Pakistani general, said Sharif had the backing of the nation's powerful army.

"I think the army is backing (his decision to attend) otherwise he would not go. He does not go against the advice of the army," he told AFP.

Either way, "Pakistan conveyed a positive gesture to India", said the chairman of the religious right-wing party Jamiat Ulema-e-Islam (JUI), an ally of Sharif's government.

"The decision to attend... is a welcome sign," said Maulana Fazalur Rehman, who also head a parliamentary special committee on Kashmir. He added that close ties with India "may help resolve the Kashmir issue".

Omar Abdullah, the chief minister of Indian-held Kashmir, echoed similar sentiments.

"I hope that this will mark a new beginning in ties between our two countries. The people of J & K (Jammu and Kashmir) will be watching closely," he said on Twitter.

"Can't help feel sorry for others taking oath or attending because the only photo op that will matter now will be the Modi-Sharif handshake."

Besides the disputed Kashmir region, the key issues straining the relationship between Pakistan and India include an Islamist militancy inside India which New Delhi frequently accuses Pakistan of backing.

Bilateral ties have only slightly recovered from the rock bottom they hit after the 2008 Mumbai attacks in which 166 people were killed by Pakistani gunmen.

For its part, Pakistan accuses India of funding a long-running insurgency in its southwestern Baluchistan province.

While Pakistan's civilian leaders and business community are in favour of closer ties, many ordinary people revile Modi, who is tainted by communal riots in his home state of Gujarat 12 years ago that killed 1,000 people, mostly Muslims.

His campaign manifesto included pledges for a more muscular foreign policy, vowing a re-think of India's no-first strike nuclear policy and a hard line on Kashmir.