SAN JUAN, P.R. — It was 11 p.m. on the Friday after Election Day, and two likely candidates to be New York City’s next mayor — Corey Johnson, the Council speaker, and Ruben Diaz Jr., the Bronx borough president — were deep in conversation under purple-lit palms outside a beachfront hotel .

Inside, the New York attorney general, Letitia James, danced atop a platform in a roped-off club at an exclusive party hosted by a New York City public employee union. Lobbyists for various clients swayed to the beat, mingling near the State Assembly speaker and Brooklyn’s district attorney.

It is perhaps the most unusual gathering in New York politics, held 1,600 miles away: the annual exodus of the state’s political class to Puerto Rico.

The vibe is something like a spring break pilgrimage for public officials and the lobbyists who woo them, where mojitos accompany talk of prevailing wages and the traditional “talk to my staff” culture melts away.