Hillary Clinton, in a surprise appearance at an annual New York City press dinner Saturday night, playfully needled Mayor Bill de Blasio for waiting six months to throw his support behind her presidential candidacy.

“I just have to say thanks for the endorsement, Bill. It took you long enough,” Clinton told de Blasio from the stage of the Inner Circle roast by city political journalists at the New York Hilton in Manhattan.

Clinton also poked fun at her own misadventure with a MetroCard at a Bronx subway turnstile during a campaign event last week.

See alsoDelegate tracker2016 election2016 Voters Guide: What to know More coverageThe 2016 campaign: Complete coverage

“Could you just fix those MetroCard slots?” Clinton demanded of de Blasio. “It took me like five swipes. The little terminal thing kept saying ‘Please swipe again.’ You’ve got to fix that. You don’t have to worry about horses any more. Fix the turnstiles.”

The “horses” line was a dig at de Blasio’s failed efforts to hold together a compromise to place new limits on the Central Park carriage horse business.

The Inner Circle show is a tradition dating back to 1923. It is staged by present and former City Hall journalists. The first two musical comedy acts lampoon the mayor and other city, state and federal politicians, and the mayor answers in kind in the third act. About $100,000 is raised for charity.

advertisement | advertise on newsday

This year’s title was “Shamilton” — a takeoff on the Broadway hit “Hamilton.” In place of one of its main plot lines — the tragic feud between Alexander Hamilton and Aaron Burr — “Shamilton” took aim at the enmity between de Blasio and Gov. Andrew M. Cuomo.

To the tune of “The Rain in Spain” from the musical, “My Fair Lady,” New York City first lady Chirlane McCray was portrayed singing, “The reign of pain is Andrew’s fav-rite game.” Pope Francis shows up and is asked to bring peace between the mayor and governor, but declines: “I don’t do miracles, sister.”

The Cuomo character offers revised lyrics to Billy Joel’s “Scenes from an Italian Restaurant:”

Get the Newsday Now newsletter!

The best of Newsday every day in your inbox.

“A bottle of white

“A bottle of red

“I won’t be happy til his dreams are dead.”

The tension between de Blasio and Cuomo builds until, like Hamilton and Burr, they meet for a duel. But instead of exchanging shots from pistols, their weapons are pies.

In the mayor’s rebuttal act, Burr — played by Leslie Odom Jr. from the Broadway show’s cast — coaches de Blasio to boast about his accomplishments in hip-hop style. After several stumbles, the mayor catches on: “I’m the illest mayor to run New York.”

advertisement | advertise on newsday

Other stars appearing in de Blasio’s segment included actor Steve Buscemi, reading mean tweets about the mayor. Sample: He’s “a Communist who slept with Fidel Castro.”

In addition to Clinton, the 2016 presidential candidates were targets of several songs and jokes, including Donald Trump.

In an opening video segment, former Rep. Anthony Weiner (Twitter handle Carlos Danger) walks along a street, looks at his phone and says, “I can’t believe the crazy stuff that guy puts on Twitter.”