Pakistan's Prime Minister Shehbaz Sharif on Monday offered a brief congratulations to his counterpart Narendra Modi on his re-election in rival India, almost a week after the results came in.

Born out of the partition of British-ruled India in 1947, the neighbours have fought two wars over the disputed territory of Kashmir.

"Felicitations to @narendramodi (Modi) on taking oath as the Prime Minister of India," he posted on X, in the first official comments from Pakistan.

Modi was sworn in on Sunday at a ceremony attended by South Asian leaders from Bangladesh, the Maldives and Sri Lanka, however neighbouring rivals China and Pakistan were not present.

The neighbours currently have minimal relations and ties have worsened during a decade under Modi, who has ramped up his Hindu nationalist agenda.

Sharif's brother and ex-prime minister Nawaz Sharif attended the inauguration of Modi in 2014, a first in the history of the nuclear-armed nations.

"Your party's success in recent elections reflects the confidence of the people in your leadership," Nawaz Sharif posted on X, formerly Twitter. "Let us replace hate with hope."

Analysts say Nawaz, the eldest Sharif brother, wields an outsized role behind the scenes of Pakistan's premiership.

Pakistan suspended bilateral trade and downgraded diplomatic ties with New Delhi in 2019, after Modi revoked the limited autonomy of Indian-administered Kashmir in a move widely celebrated across India.

The arch-rivals regularly trade accusations of espionage and of stoking militancy in each other's territory.

Pakistan's recently elected premier has previously hinted at wanting to improve ties with India.

But analysts say Pakistan, a sixth of the size of India, has few levers to pull.

Modi's "election campaign pivoted around anti-Muslim and anti-Pakistan rhetoric," Zahid Hussain, an opinion writer and author, said in the country's leading English-language newspaper Dawn.

"Modi's campaign narrative made it absolutely clear that under his dispensation, the Muslims will be politically disempowered, economically marginalised, and deprived of their constitutional rights," he said following the vote.