President Trump will visit Mayor Zohran Mamdani on Monday at the mayor’s official residence at Gracie Mansion in New York City, according to the mayor’s office.

A spokeswoman for the mayor said the meeting will “focus on issues affecting New York City and New Yorkers.”

The president will be in New York for the U.N. General Assembly, where he is scheduled to speak on Tuesday. A White House spokesman confirmed the visit.

This would be the president’s first visit with Mr. Mamdani on the mayor’s home turf, but not the first time the two leaders have met.

Mr. Mamdani twice traveled to Washington to meet with the president, first as mayor-elect in November, and then as the sitting mayor in February.

During those meetings, the two leaders from opposing ends of the political spectrum managed to strike up a surprisingly amicable relationship, despite their history of mutual public derision, and despite members of Mr. Trump’s party having used Islamophobic terms to demonize the city’s first Muslim mayor. (Mr. Trump himself has attacked a Michigan Democratic Senate nominee who is Muslim, but has been comparatively gentle with Mr. Mamdani, to a degree that has confused some of his own allies.)

It remains unclear what precisely the two men will talk about. The president’s deportation agenda remains a source of tension between him and Mr. Mamdani, who has accused the Trump administration of criminalizing “the very act of being an immigrant.”

Infrastructure might also come up. During Mr. Mamdani’s most recent visit to the White House, he pitched the president on Sunnyside Yard, an 180-acre train yard on which the city has long dreamed of building thousands of apartments. The city envisions building a platform over the yards that it says would require at least $21 billion in federal grants.

The mayor has since indicated the project remains a matter that city and federal officials are discussing, but no discernible progress has taken place since that February meeting.

This is not the first time Mr. Trump has visited Gracie Mansion, though it is his first time as president. He visited twice when Michael R. Bloomberg was mayor. (Mr. Bloomberg, unusually, did not live at Gracie Mansion, preferring instead to reside at his own mansion nearby.)

In 2003, Mr. Trump attended Rudolph W. Giuliani’s wedding at Gracie Mansion after Mr. Giuliani had left office. And in 2007, Mr. Trump and his wife, Melania Trump, attended a book party for Representative Charles Rangel at Gracie. Both events were hosted by Mr. Bloomberg, then the mayor.

Nor is this the first time a president has visited Gracie Mansion, though such visits are rare. In 1949, President Harry S. Truman visited Gracie Mansion for an official luncheon hosted during the United Nations cornerstone-laying ceremonies in New York.

In 1962, President John F. Kennedy visited Gracie Mansion to deliver a major speech on medical care for the aged to a gathering of U.S. mayors. And two decades later, in 1981, President Ronald Reagan visited Gracie Mansion to present a stage-prop check to Mayor Edward I. Koch symbolizing his administration’s commitment to the Westway project on Manhattan’s West Side. (The project never ultimately came to fruition.)

Decades later, the tradition is being revived by Mr. Trump and Mr. Mamdani, a prospect that would have been unthinkable just a year ago. Mr. Mamdani has called Mr. Trump a fascist and a despot; Mr. Trump has called Mr. Mamdani a “lunatic” and even derided his looks.

“He looks TERRIBLE, his voice is grating, he’s not very smart,” Mr. Trump said after Mr. Mamdani won the Democratic primary last year.

But at their first meeting in November, Mr. Trump lavished praise on the incoming mayor and even helped him deflect questions from the media, including one asking the mayor whether he still considered the president a “fascist.”

Mr. Trump jumped in: “That’s OK, you could just say, ‘Yes,’” he told Mr. Mamdani, patting him on the arm.

During his State of the Union address, Mr. Trump said he spoke often to Mr. Mamdani and described him as a “nice guy,” even if he embraced “bad policy.”

In February, the mayor gave Mr. Trump a mock New York Daily News front page featuring a flattering photo of the president and the headline, “Trump to City: Let’s Build,” as part of his Sunnyside Yard push.

During the meeting, Mr. Mamdani mentioned the plight of a detained Columbia University undergraduate; soon after the meeting, Mr. Trump called Mr. Mamdani to tell him that the student, Elmina Aghayeva, would be released. Columbia later confirmed that she had been freed.