NEW YORK— A federal judge on Thursday denied bail for Jeffrey Epstein, the financier facing sex-trafficking charges, rejecting his request to await trial under home detention at his Upper East Side mansion.

The judge, Richard M. Berman of U.S. District Court in Manhattan, said Epstein, who owns property in Paris and has a private plane, would be detained in jail until his trial on charges that he sexually abused and trafficked dozens of underage girls in the early 2000s.

Prosecutors had opposed Epstein’s proposal to remain in his mansion guarded by private security, saying he was seeking “special treatment” and trying to build his own private jail — a “gilded cage,” prosecutors wrote.

They had also argued that Epstein’s vast wealth, said to be more than $500 million, would make it possible for him to flee the country if he were not held in jail.

Ever since his July 6 arrest at Teterboro Airport in New Jersey after a flight from Paris, Epstein, 66, has been detained at the Metropolitan Correctional Center, a highly secure jail in Manhattan that has housed accused terrorists, mobsters and even the Mexican cartel leader known as El Chapo.

A federal indictment charged that between 2002 and 2005, Epstein and his employees paid dozens of underage girls to engage in sex acts with him at his homes in Manhattan and Palm Beach, Florida.

The indictment also accused Epstein of using some of his victims to recruit additional girls for him to abuse. He paid his “victim-recruiters” hundreds of dollars for each girl they brought to him, prosecutors said.

He has pleaded not guilty and has vowed to fight the charges, his lawyers said. If convicted, he faces up to 45 years in prison.

In 2008, Epstein pleaded guilty to two state prostitution charges in Florida as part of a secret, lenient deal he negotiated with the U.S. attorney in Miami to avoid federal prosecution. He served 13 months in jail.

Epstein’s lawyers had argued that he should be allowed to remain at home pending trial because he has lived a law-abiding life since 2005.

They said he would post a substantial bond, secured by his mansion and private jet, would wear an ankle bracelet tracking his location, and would surrender his passport and ground his jet.

But prosecutors argued Epstein should remain jailed because he was a risk to flee and a danger to the community.