Embattled Brooklyn state Senate candidate Julia Salazar said she was accused of having an affair with Mets legend Keith Hernandez — and of stealing cash and booze from his ex-wife’s house, according to a newly uncovered lawsuit.

Salazar, who has come under fire for embellishing her past while running against incumbent state Sen. Martin Malave Dilan in the Democratic primary, made the claims in a 2013 defamation suit against Kai Hernandez in Florida.

Kai had hired then-19-year-old Salazar, a family friend, to house-sit for her in 2010 while she was divorcing Keith — then reported the teen to police for allegedly using information she gleaned during the stay to access Kai’s bank account.

She also told cops she thought Salazar had swiped more than $10,000 in cash, Pottery Barn vouchers and wine from her Jupiter abode — and allegedly claimed the teen was having an affair with the baseball great, according to the suit.

The charges were dismissed — but not before Salazar, now 27, was “humiliated” by the arrest, she says in the suit.

Salazar claims Kai made up the accusations after she found drug paraphernalia and guns in the house and told Keith about them, and he subsequently went to the police.

Kai’s attorney says her client never accused Salazar of having an affair with Keith, and the political hopeful only raised the hanky-panky issue in her defamation suit to try to prove malice.

“Julia alleged that Kai believed Julia was having an affair with Keith. Kai never said that and never thought that,” lawyer Lynne Ventry told The Post.

“They were trying to come up with a reason of why Kai would do this.”

Ventry says Kai actually called the cops after her bank alerted her that someone seemed to be trying to access her account.

When the bank played a recording of a woman trying to access the account over the phone and change its password — successfully answering security questions including her date and place of birth and Social Security number, but failing to name her high school — she says she instantly identified the voice as Salazar’s.

“I immediately recognized the voice as that of Julia Salazar, the young woman who had been my house-sitter in September, 2010 — the same time $11,800 in cash and $1,175 in Pottery Barn gift cards and approx. $950 worth of wine disappeared from my home,” she said in a statement to police.

The police detective assigned to the case told Tablet magazine he identified the voice as Salazar’s, but the charges were dropped because the state attorney general’s office needed more than a voice ID for a conviction.

Former Detective Charles Weinblatt couldn’t confirm the affair claim was made — and it doesn’t appear on the police report — though he told the outlet it sounded “vaguely familiar.”

The defamation suit ultimately was settled between the two women in 2017 — with Kai paying out $20,000, Salazar’s lawyer says.

“Kai Hernandez’s bizarre and fraudulent attempts to defame and victimize Julia were recognized as baseless by the authorities, who declined to file charges, and this matter was resolved with a monetary settlement of $20,000 in Julia’s favor,” said attorney Adam Hecht in a statement.

“Keith, Kai and Julia agree that there was no affair. We have no further comment on this.”

Salazar, who shot to prominence after the success of fellow young, insurgent, socialist candidate Alexandria Ocasio-Cortez, is facing criticism after portraying herself as a Colombian-born “proud immigrant” from a working-class family — only for her relatives to reveal she was born into a middle-class household in Florida.

She later clarified that she grew up moving back and forth between the two countries, but her brother told City & State they made only a handful of brief trips to Colombia, where her father was born.

Salazar identifies as Jewish through her late father’s side — though her Catholic family says he wasn’t. Her mom told the New York Times recently that his family has Sephardic roots in Spain.

Her website also claims she “supported herself through Columbia University as a nanny” — although the Times notes she never actually graduated from the Ivy League institution.