Supporters hope that Nawaz Sharif’s visit to India, a historic first for the two often hostile neighbors, will lead to better relations. (Mian Khursheed/Reuters)

Pakistani Prime Minister Nawaz Sharif said Saturday that he will attend Narendra Modi’s swearing-in as India’s prime minister Monday, a historic first for the two often-hostile neighbors.

Pakistan’s Foreign Ministry said Sharif will lead a delegation to New Delhi to attend the event at India’s Rashtrapati Bhavan — the president’s official residence — Monday evening, along with leaders from other South Asian countries, including Afghan President Hamid Karzai. Officials said it will be the first time a Pakistani leader has attended such a celebratory gathering in India. Sharif and Modi are also scheduled to meet Tuesday morning.

After a decisive win by his Bharatiya Janata Party (BJP) in the recent Indian parliamentary elections, Modi, a Hindu nationalist, surprised observers in both countries when he invited Sharif to attend his inauguration. Supporters hope his move will improve relations between the two countries, which have been bitter rivals since Muslim-majority Pakistan was split off from India when the latter won its independence in 1947.

“We want peace for our next generations, and that is why we want to engage India in dialogue,” Pakistan’s information minister, Sen. Pervaiz Rashid, told journalists in Lahore, noting that the BJP will rule India for the next five years and that Pakistan will “have to deal with it.”

Nirmala Sitharaman, spokeswoman for Modi’s party in India, said party officials were “happy” to hear of Sharif’s “goodwill gesture.”

Sharif, who began his third term as prime minister last June after years of exile in Saudi Arabia, has stressed in recent months his hopes for better ties with India. In September, he met briefly with outgoing Indian Prime Minister Manmohan Singh in New York during the U.N. General Assembly. Representatives for Sharif and Singh also discussed ways to bolster trade.

Sharif “is burning yet more political capital, and that is why I think this is incredibly courageous,” said Mosharraf Zaidi, an Islamabad-based political analyst who served as an adviser to Pakistan’s foreign secretary from 2011 to 2013. “He is knee-deep in a series of domestic crises, so going makes it a lot harder for him to plow through opposition, but if he does, it could be transformational for Pakistan and the region.”

Experts and diplomats in India say the move signals a more muscular and visible foreign diplomacy from Modi, who has little formal experience in that arena. He had served as chief minister of the western state of Gujarat since 2001, and he has long been criticized for failing to stop religious riots there in 2002 that left more than 1,000 dead, many of them Muslims.

On the campaign trail, he largely avoided anti-Muslim rhetoric, preferring to keep to his message of economic opportunity. He has often said he admires the legacy of India’s last prime minister from the BJP, Atal Bihari Vajpayee, who reached out to Pakistan during his 1998-2004 tenure and is famous for having taken a bus from Delhi to Lahore to foster good relations. Vajpayee was met at the border by Nawaz Sharif, who was also then Pakistan’s prime minister.

But Modi has also said that the bloodshed between the two countries must stop before progress can be made.

“Do you think it is possible to have a discussion amidst the deafening noise of bomb blasts and gunshots?” he said in an interview this month on the television station Times Now.

Although India and Pakistan have not fought a major ground war since 1999, relations between the two, particularly along their disputed border in Kashmir, remain tense. Starting last summer and continuing throughout the fall, the two armies repeatedly lobbed rockets across the border in what military leaders in both countries called the worst border violence since a 2003 cease-fire.

“I hope that this will mark a new beginning in ties between our two countries,” Omar Abdullah, the chief minister of the state of Jammu and Kashmir, wrote Saturday on Twitter. “The people of J&K will be watching closely.”

While most analysts say they do not doubt the sincerity of Sharif’s hope for warmer ties, they say he had to carefully consider the possible political ramifications of such a visit. Just hours after the Indian government said it had invited Sharif, India’s consulate in Herat, Afghanistan, was attacked by four gunmen who were eventually killed by security forces.

On Friday, India’s Ministry of External Affairs cautioned against concluding that the events were linked, saying the investigation had just begun, but opposition politicians in India took note.

Within hours of the announcement, opposition to Sharif’s visit was building in Pakistan as well.

Hafiz Mohammad Saeed, the leader of the anti-India Jamaat-ud-Dawa and the man many believe was the mastermind of the 2008 terrorist attacks in Mumbai, told reporters that Modi’s decisive victory should serve as a warning to Pakistanis that India is “not a secular country.”

“The new Indian prime minister holds extremist views, and we can’t ignore this fact,” Saeed said, according to Geo TV. “Sharif must review his decision to attend.”

Javed Ashraf Qazi, a former chief of Pakistan’s Inter-Services Intelligence agency, also questioned Sharif’s plans.

“Mr. Modi has so far been hostile to Pakistan. Look at his election campaign and his speeches,” Qazi said in an interview. “He has not come up with any positive gesture. I don’t understand why, then, our prime minister is in a rush to go there. What good would it bring to Pakistan, to its people?”

Gowen reported from New Delhi, along with Jalees Andrabi. Shaiq Hussain contributed from Islamabad.