A fight between high-school girls led to billionaire Jeffrey Epstein being busted on charges of having sex with underage teens – but infighting between police and prosecutors resulted in most of the raps going belly up, The Post has learned.

Despite an earlier claim that Epstein was backing out of a plea deal, he is resolute and will plead guilty in January to a single charge of soliciting an underage prostitute in Florida, sources close to the case said. The money manager’s lawyer, Gerald Lefcourt, declined comment.

The single felony charge – and the 18-month prison term Epstein is expected to get in return for a plea – is a slap on the wrist compared to what Palm Beach police had recommended at the end of their 11-month investigation last year.

Cops had wanted prosecutors to slam Epstein with five felony counts stemming from “massages” he had received from as many as four underage girls – but the vast majority of those claims have disintegrated, thanks to questionable witnesses and misrepresentations from cops, a source close the case said.

The investigation started in 2005, after cops were called to a Palm Beach-area school because of a fistfight between two teenage girls, the source said. The teens told the cops the fight had started after one accused the other of being a prostitute.

One of the girls, 14, told cops she had indeed been paid $300 for going to the estate of an older man named “Jeff” and partially stripping while giving him a massage. She also said he used a “purple vibrator” on her, records show.

The girl told cops she had been taken to Jeff’s by a friend of a friend named Haley Robson. Robson told cops the teen was one of six girls between 14 and 16 whom she had taken to Epstein’s.

Cops tracked down the girls, and some told very similar stories – they had been taken to Epstein’s house by Robson and had been paid to give him massages in various states of undress. Some said he groped them, and in the most serious case, one said he had coerced her into having lesbian sex and forced himself on her.

Cops launched their probe, which included regularly sifting through Epstein’s garbage. The digging led cops to more phone numbers for more girls and to some disturbing finds, including pieces of what appeared to be a broken sex toy.

They executed search warrants at Epstein’s home and found numerous pictures of naked young women on his walls and video cameras hidden around his house.

Police presented their findings to prosecutors. The prosecutors, however, found numerous cracks. The “sex toy” pieces turned out to be a broken salad-server handle. The numbers cops found led to women who were 18 or older when they went to Epstein’s.

Police also hadn’t told them that one of their key witnesses, Epstein’s former housekeeper, Juan Alessi, had been fired and arrested after getting caught on Epstein’s video cameras stealing money. Alessi had told cops that Epstein would have three young girls a day over for massages.

A review of Robson’s taped interview showed that she had told investigators that Epstein had never asked her to bring underage girls and that she had told the girls she took him to say they were 18. The 14-year-old had told cops she told Epstein she was 18 because Robson warned her, “If you’re not, he won’t let you in his house.”

Most damaging to the case, the girl who cops said Epstein had sex with told police that the tryst with the other woman was her idea, that she invited Epstein to join in – and that she was actually 18 at the time. Epstein passed a polygraph test, during which he was asked whether he knew that any of the girls he had been seeing were under 18, records show. He also underwent a psychosexual exam, in which a doctor found he was neither a pedophile nor a sex addict, the source said. Epstein’s lawyers offered the results of both tests to cops, who said they weren’t interested.

Prosecutors presented everything they had to a grand jury, which returned the lone solicitation-of-prostitution charge. That outraged Police Chief Michael Reiter, who sent the head of the State Attorney’s Office a letter accusing him of mishandling the case.

Meanwhile, Epstein is being sued in Manhattan by Maximilia Cordero, a transgendered model who claims he forced her into a sexual relationship when she was 16.