Convicted pedophile Jeffrey Epstein kept a stash of lewd photos locked in a safe in his $77 million Upper East Side mansion, where authorities also found kiddie porn, the feds revealed Monday as they charged the multimillionaire with child sex trafficking.

Federal agents and NYPD officers cracked into the freestanding safe after they broke through the heavy oak doors to Epstein’s $77 million mansion and executed a search warrant late Saturday and early Sunday, according to court papers tied to Epstein’s sex-trafficking indictment.

The free-standing safe was found “in plain sight” in a room on the third floor of the seven-story townhouse at Nine East 71st St., according to a law enforcement source familiar with the matter.

Authorities found some photos stashed inside, along with “compact discs with hand-written labels including the following: ‘Young [Name] + [Name],’ ‘Misc nudes 1,’ and ‘Girl pics nude,’” court papers said.

Prosecutors said the “vast trove of lewd photographs” was part of the “devastating evidence” against Epstein, 66, whose famous former friends have included former President Bill Clinton, Great Britain’s Prince Andrew, Donald Trump and former Harvard Law School professor and lawyer Alan Dershowitz.

The effort to crack the heavy-duty safe produced so much smoke that a window had to be opened — prompting a 911 call that sent firefighters racing to the scene around 4:30 a.m. Sunday, the source said.

The raid turned up “at least hundreds — and perhaps thousands — of sexually suggestive photographs of fully- or partially nude females” kept by the unmarried financier, court papers said.

Some of the photos “appear to be of underage girls, including at least one girl who, according to her counsel, was underage at the time the relevant photographs were taken,” according to the Manhattan federal court filing.

The two-count indictment unsealed Monday charges Epstein with sex trafficking and conspiracy for allegedly luring girls as young as 14 to his townhouse and a $12 million estate in Palm Beach, Fla., where he “sexually exploited and abused” them between 2002 and 2005.

But authorities cautioned the investigation was “ongoing,” with prosecutor Alex Rossmiller saying in court that more alleged victims have come forward since Saturday night and that additional arrests were “certainly possible down the road.” He didn’t elaborate.

Epstein was aided by three unidentified employees who helped him create a “vast network of underage victims” between Manhattan and Palm Beach, according to the indictment.

If convicted on both counts, Epstein would face up to 45 years in prison.

Monday’s charges followed an award-winning expose last year in the Miami Herald that detailed the sweetheart plea deal Epstein struck in 2008 in Florida, where he served just 13 months of an 18-month sentence for two counts of solicitation of prostitution, one involving a minor.

“The defendant, a registered sex offender, is not reformed, he is not chastened, he is not repentant; rather, he is a continuing danger to the community and an individual who faces devastating evidence supporting deeply serious charges,” according to Monday’s court filing.

In a footnote, prosecutors cited remarks Epstein made to The Post in 2011, when he tried to downplay his notorious reputation.

“I’m not a sexual predator, I’m an ‘offender,’” he claimed. “It’s the difference between a murderer and a person who steals a bagel.”

Epstein’s indictment describes in graphic detail how he allegedly paid the teens hundreds of dollars each to give him nude “massages” that would become “increasingly sexual in nature.”

“During the encounter, Epstein would escalate the nature and scope of physical contact with his victim to include, among other things, sex acts such as groping and direct and indirect contact with the victim’s genitals,” the papers allege.

“Epstein typically would also masturbate during these sexualized encounters, ask victims to touch him while he masturbated, and touch victims’ genitals with his hands or with sex toys.”

Prosecutors said that the raid on Epstein’s townhouse says should be forfeited as uncovered a special “massage room” outfitted with a table and an assortment of sex toys.

The indictment seeks forfeiture of the mansion on grounds it was “used to commit or to facilitate” Epstein’s crimes.

In addition to paying girls for the “massages,” Epstein also “incentivized his victims to become recruiters” by giving them cash to bring in other girls, supplying him with “a steady stream of minor victims,” according to the indictment.

Epstein “intentionally sought out” girls under 18 — and knew they were underage because some told him how old they were, the feds charge.

“The alleged behavior shocks the conscience and while the charged conduct is from a number of years ago, it is still profoundly important to the alleged victims,” Manhattan US Attorney Geoffrey Berman said at a morning news conference.

“They deserve their day in court and we are proud to be standing up for them by bringing this indictment.”

Officials didn’t detail how Epstein sought out his alleged victims, but a Miami Herald report cited allegations from a civil lawsuit that said he used an international modeling agency, Mc2, to recruit girls from Europe, Ecuador and Brazil.

Epstein paid for the girls’ visas and housed them in a building he owned in New York, the Herald said, citing a sworn statement from the agency’s former bookkeeper.

The agency’s owner has denied any wrongdoing.

Epstein, a former options trader for since-shuttered Bear Stearns, in 1982 founded a money-management firm that purportedly catered exclusively to billionaires.

His exact net worth is unknown, according to Forbes. His lawyers have said his fortune is “is in excess of nine figures,” but an attorney who has represented three of his alleged victims told the magazine that he never provided any proof of that.

Epstein was arrested around 5:30 p.m. Saturday when he stepped off a private jet at Teterboro Airport in New Jersey, where he arrived following a flight from Paris. He was locked up in Lower Manhattan’s infamous Metropolitan Correctional Center, was hauled into court Monday wearing a blue prison outfit and orange, slip-on sneakers.

When asked how he pleaded, he answered, “Not guilty, your honor.”

Prosecutors argued that Epstein should be held without bail pending trial, with court papers saying that there’s an “exceptionally high” risk he’ll try to run away and that his release “would pose a significant threat to the community and to the ongoing investigation.”

The filing provided numerous examples of his “vast wealth,” including the townhouse and Palm Beach estate, as well as a home in Paris and his primary residence, which is a private island in the US Virgin Islands.

“His sex registration documentation of ‘current vehicles’ lists no fewer than 15 motor vehicles, including seven Chevrolet Suburbans, a cargo van, a Range Rover, a Mercedez-Benz sedan, a Cadillac Escalade and a Hummer II,” prosecutors said.

Epstein — who has no kids or other immediate family — also has access to two private jets and has been recorded by US Customs and Border Protection flying to or from a foreign country more than 20 times since Jan. 1, 2018, according to court papers.

Prosecutors said “there can be little doubt that the defendant is in a position to abandon millions of dollars in cash and property securing any potential bond and still live comfortably for the rest of his life” and noted that he holds three valid US passports.

The court papers also cite “credible allegations” that Epstein has a history of “witness tampering, harassment or other obstructive behaviors” that included paying private investigators who tailed the father of an accuser in Florida and forced his vehicle “off the road.”

Defense lawyer Reid Weingarten didn’t present any arguments in favor of bail and instead asked for a hearing that was set for Monday.

Weingarten also described the photos seized from Epstein’s apartment as “ancient” and “pre- his spending time in prison and/or erotic pictures of adults voluntarily engaged in the conduct.”

He declined to comment outside court.