NEW YORK – This NYPD love square is a tangled affair. You’ve heard of a love triangle, but this story has four corners — and there is a police badge in each one.

An NYPD sergeant cheated on his cop girlfriend with a fellow officer, whose husband is also on the job — and the bosses took away everyone’s guns so they wouldn’t kill each other, sources told The New York Post on Monday.

Sgt. Kandou Worley, 40, and Officer Stephanie Gallardo, 33, were both assigned to the department’s Strategic Response Group when they were involved with one another last year, according to an internal NYPD document.

But their secret was revealed when Worley’s live-in girlfriend, Tyeis Coppin, a union delegate in the 32nd Precinct, found incriminating photos on his cellphone.

One image in particular shows Gallardo, with her hair wet, gazing into the eyes of Worley, who has beads of water on his chest.

More intimate photos show Worley nuzzling Gallardo’s face and kissing her cheek, and Gallardo snuggling into Worley’s chest while he caresses the back of her head, according to the Post.

NYPD love square

NYPD Sgt. Kandou Worley and Officer Stephanie Gallardo. (Instagram)

In a fit of vengeance, Coppin, 41, allegedly posted the photos to Worley’s Instagram account, which bears the username “mike_lowry_78” — an apparent reference to the ladies-man detective played by Will Smith in the “Bad Boys” movie franchise.

Captions say “I told my girl I loved her 10 mins b4 I f–ked this one,” and “She’s someone’s wife, she’s not my girl tho. I have one and this is not her!!!!”

On the day after Christmas, Worley — who a source said served as Gallardo’s supervisor — warned her that the photos were online, and the NYPD learned about them two days later.

As a result, Gallardo was called in for questioning, and admitted that she and Worley had a “personal relationship” during September and October.

Nevertheless, Gallardo said that she’d been separated from her husband, fellow SRG Officer Cristian Gallardo, 28, since March. However, they reportedly still live together and are raising their 20-month-old daughter.

She also claimed “that with the exception of kissing while together off-duty on a number of occasions, the relationship [with Worley] was not intimate.”

The NYPD report says a total of nine handguns were seized from all four cops under a section of the Patrol Guide that permits impounding firearms in “non-disciplinary cases,” including those involving “stress as a result of family or other situations.”

A law-enforcement source said the circumstances raised “the potential for violent outcomes due to the sensitive nature of infidelity and everyone having access to guns.”

The Dec. 30 report also says the entire mess was turned over to the Special Operations Division Investigations Unit for further review, “including a review of social media.”

Yet all four officers had their firearms returned and sent back to work in their original assignments during the past week, pending results of the SOD investigation, an NYPD spokesman said.

Lt. John Grimpel also said that the NYPD Patrol Guide doesn’t prohibit relationships between cops — even involving a superior and a subordinate — “except if you’re a police supervisor in the police academy.”

“Any police officer in the academy cannot have a relationship with a recruit in the academy,” Grimpel said.

Worley and Stephanie Gallardo both declined to comment when they answered the doors at their respective homes on Monday afternoon.