Remy Ma thrilled the hundreds of fans who packed Irving Plaza last year for a concert that featured surprise cameo appearances by more than a half-dozen other New York rappers.

The parade of guest stars climaxed with an appearance by Grammy winner Lil’ Kim, who joined Ma onstage for a performance of their 2017 collaboration, “Wake Me Up.”

Billboard said Ma more than lived up to her “Bronx Savior” nickname.

But Ma’s devotees weren’t the only ones who showed up for the sold-out March 16, 2018, event.

The NYPD secretly planted an undercover cop inside the venue to keep an eye on the crowd — as two dozen of the officer’s uniformed colleagues patrolled outside the historic, ballroom-style theater near Union Square.

A special branch of the department’s Intelligence Division had been secretly keeping tabs on Ma — who had served six years in prison for a 2007 shooting — and a member of her entourage, Jahmeek “Jah” Elliot, according to internal police records exclusively obtained by The Post.

The documents are among hundreds of pages that reveal the inner workings of the NYPD’s Enterprise Operations Unit, also known as the Rap Unit.

Officers assigned to the unit draw up weekly entertainment reports about scheduled hip-hop shows at city clubs, and designate each as posing a low, medium or high risk for violence or other crimes.

That information is passed on to local precinct commanders and intelligence officers in the field, with local cops in turn flagging shootings and other incidents associated with clubs in their precincts.

The records tie the cops assigned to the Rap Unit to a program called the New York/New Jersey High Intensity Drug Trafficking Area, which uses federal money and resources — including Drug Enforcement Administration agents — to crack down on narcotics production and sales.

At the time of last year’s concert, neither Ma nor Elliot was wanted for a crime, although Ma — whose real name is Reminisce Mackie — was busted earlier this month in an alleged attack on her “Love & Hip Hop New York” co-star Brittney Taylor backstage during a benefit concert at Irving Plaza this past April 16.

Ma, who’s still on parole for the shooting, has pleaded not guilty in the assault case and rejected a plea deal offered by prosecutors last month. Her misdemeanor trial is set for July 12.

But the NYPD documents show cops considered Elliot a “person of interest” due to his suspected gang ties and a rap sheet listing 26 arrests.

In 2012, Elliot was among three reputed leaders of the Bronx-based Dub City drug gang who were indicted in connection with a violent turf war that authorities said involved 15 shootings, including one that killed a Dub City member.

Elliot later served a prison sentence of 2½ years for felony drug possession before being paroled in November 2016, according to state records.

An undated memo written by two NYPD intelligence officers assigned to Manhattan’s 13th Precinct, which covers Irving Plaza, said that before joining Dub City, Elliot had “previously been associated with a known crew known as the ‘Mac Ballas.’ ”

“Intel revealed that Jahmeek’s new crew association has caused tension with the ‘Mac Ballas,’ and there may be possible retaliation against [him],” the memo says.

A phone number in Elliot’s name was no longer working and he couldn’t be reached.

Ma’s lawyer, Dawn Florio, denied any connection between Elliot and her client.

“Remy does not know Jahmeek Elliot. Never heard of him, doesn’t know him,” Florio said.

“She does not travel in an entourage. She travels with her husband and security guards.”

Florio also said she’s “not a fan” of the NYPD’s Rap Unit, which she disparagingly referred to as the “hip-hop police.”

“My impression of the hip-hop police is they’re this shadowy, specialized unit that conducts overly aggressive investigations,” she said. “They’re constantly stalking high-profile rap artists and monitoring their every move.”

Sgt. Jessica McRorie, an NYPD spokeswoman, said, “The Enterprise Operations Unit focuses on venues or entertainers that have been connected with past acts of violence — regardless of musical genre. The primary goal of EOU is to anticipate, based on past incidents, where there is a significant likelihood of violence, and to take steps to prevent people from being hurt, or worse.”

McRorie also credited the unit with aiding “several major prosecutions,” and said it “continues to gather additional intelligence by responding to shootings and assaults that may occur at all kinds of entertainment venues.”

The documents obtained by The Post show the Rap Unit helped plan policing strategies at a since-shuttered nightclub in Sunset Park, Brooklyn, where records show Ma hosted an afterparty following the Irving Plaza concert.

Club Lust was a popular spot for big-name rappers, including Curtis “50 Cent” Jackson, who celebrated his birthday there in 2017.

The previous year, he was scheduled to perform at the club, prompting a sergeant at Patrol Borough Brooklyn South to reach out to several high-ranking officers at the local 72nd Precinct, an email shows.

“Any plan being put into effect for 50 Cent appearing on Thursday at Club Lust?” the sergeant asked.

It’s unclear what police action, if any, the inquiry prompted.

Rainbow-haired rapper Tekashi 6ix9ine — who is locked up and awaiting sentencing on federal racketeering charges — was another Club Lust patron.

He appears in a YouTube video standing in front of a bar piled high with stacks of cash and making it “rain” money by tossing bills at scantily clad dancers.

Tekashi, born Daniel Hernandez, also made headlines in the rap world by posting an Instagram video shot outside the club that shows him and rapper Casanova “squashing a beef” between them in May 2018.

NYPD records show that months earlier, a New Year’s Day email was circulated among members of the Rap Unit ahead of a scheduled appearance by Tekashi at Club Lust the following night for its “Trap Tuesdays” event.

The email included an image of a promotional flier and noted that both the desk sergeant at the local 72nd Precinct and an unidentified field intelligence officer had been alerted by phone and email, respectively.

Another hip-hop artist who came under scrutiny in connection with Club Lust was Jersey City rapper AlBee Al, real name Albert Robinson.

When Al was slated to appear at Club Lust in July 2016, the Rap Unit compiled a five-page report linking him to “multiple shootings in the New Jersey state area.”

The report said Al was a “known BLOOD member” and had been acquitted of a June 2014 slaying for which his cousin was convicted and sentenced to 10 years in prison.

It also said Al was suspected of ordering a May 2016 slaying outside a club in Elizabeth, NJ, leading to a revenge shooting by the victim’s brother in which Al was wounded the following month.

“The EOU will continue to observe for any future events where Albee Al will be in attendance,” the report says.

“In addition, any of these future events that are found will be classified as High Events for future weekly Entertainment Reports.”

Al hung up when The Post called for comment.

In April 2018, records show, a 72nd Precinct lieutenant alerted the Rap Unit to an appearance at Club Lust by up-and-coming East Brooklyn rapper Billy B, real name Jahdira Atkins.

In an email, the lieutenant said the show was “being heavily promoted on Facebook” and said cops were worried about the performer’s reputed gang ties.

“We’re anticipating multiple gang members will be in attendance. The concert is being promoted by Saad Washington. He’s a documented 59 Brim Blood gang member,” the lieutenant wrote.

“Rapper Billy B is scheduled to perform that night. She’s a documented 823 G-Stone Crip.”

But a Rap Unit detective downplayed any potential danger posed by Billy B’s appearance.

“She appears to be an old associate of the CRIPS. But nothing has transpired recently. You should not have any issues,” the detective wrote.

Phone numbers listed for both Billy B and Saad Washington were no longer working, and neither responded to messages sent via Facebook.

Troubled South Florida rapper Kodak Black’s name surfaced in a Feb. 28, 2017, email exchange in which a 72nd Precinct lieutenant said his commanding officer had “some concerns” about a planned performance at Club Lust.

In response, a Rap Unit detective said, “Theres no need to worry about him.”

“Kodak is a loud mouth knuckle head. However, there have been no issues with him in NYC. In addition, hes on probation. So if he does anything wrong at all, hes going right back to jail and hes aware of that as well as his people around him,” the detective wrote.

The Rap Unit cop also noted that Black “was arrested earlier today for parole violation and is being held without bail in the state of Florida.”

“So it’s possible that and more than likely that we wont even be attending this event at Lust … If itll make your CO feel better, if he does get out of jail (which I doubt) in time to go to this event, I will reach out to him management and speak with them,” the detective wrote.

“But like I said, hes simply a big mouth young kid. He’s actually intimidated of NYC. So he just wants to fulfill his contract, [and] then leave.”

Black’s appearance was ultimately canceled, and the rapper, who was born Dieuson Octave but changed his name to Bill Kapri, is currently locked up in Miami on federal weapons charges.

He also faces sex assault allegations in South Carolina, where he’s accused of raping a high school student in his hotel room following a 2016 concert.

Another email, from August 2016, shows a sergeant assigned to Patrol Borough Brooklyn South alerting the 72nd Precinct to an appearance by a popular disc jockey, DJ Self, who hosts an overnight show on New York’s Power 105.1 radio station.

The sergeant, however, all but dismissed the event’s importance.

“When you have a moment, can you please provide the usual coverage info for Club Lust?” the sergeant wrote.

“It doesn’t seem to be anyone extraordinary, just DJ Self.”

Additional reporting by Bruce Golding