ISLAMABAD — India’s Narendra Modi made a surprise visit to Pakistan on Friday, his first such trip as prime minister to this Islamic nation that has been India’s long-standing archrival in the region.

The previously unannounced visit is a potential sign of thawing relations between the two nuclear-armed neighbors. The two heads of government also had an unscheduled meeting at the Paris climate change talks earlier this month.

Since gaining independence from Britain in 1947, India and Pakistan have fought three wars, two of them over Kashmir, the Himalayan region that both countries claim.

Modi landed on Friday afternoon in the eastern city of Lahore and met with his Pakistani counterpart, Nawaz Sharif, state-run media reported. The visit coincides with Sharif’s birthday and the wedding of his granddaughter.

Security was beefed up at the Lahore International Airport shortly before Modi’s arrival.

After spending about two hours with Modi at his residence, Sharif accompanied Modi to the Lahore airport to see him off.

Sharif and Modi held a meeting in a “cordial and positive atmosphere” and they agreed to continue working for the welfare of people of their countries, Foreign Secretary Aizaz Ahmad Chaudhry told reporters.

He said Modi called Sharif at about 11:30 a.m. on Friday and expressed his wish to visit Pakistan.

“This is how this visit was suddenly planned,” he said. Chaudhry termed Modi’s visit a “gesture of good will” and hoped that it will help resolve all of their outstanding issues when the two sides resume talks in the near future.

John Kirby, spokesman for the U.S. State Department, said the visit was a welcome one.

“As we have long said, better relations between neighbors India and Pakistan will benefit the people of the entire region,” he said.

Earlier in the day, Pakistani Foreign Ministry spokesman Qazi Khalilullah said India had informed Pakistan about the visit on Friday. He refused to share any further details.

One of the first public signs of the visit came Friday morning when Modi, during a stop in the Afghan capital of Kabul, tweeted that he is “looking forward to meeting” Sharif in Lahore, “where I will drop by on my way back to Delhi.” He said he also called Sharif and wished him a happy birthday.

Sharif’s sprawling residence had been colorfully decorated for his granddaughter’s wedding reception when Modi arrived along with the Pakistani prime minister. The two leaders were later shown sitting together in a room looking happy and relaxed.

Analysts viewed the visit as a potential turning point in Pakistani-Indian relations.

“I think it is going to play a significant role in improving ties between the two South Asian archrivals,” said Amanullah Memon, a professor of international relations at Preston University in the Pakistani capital, Islamabad.