Cyclist Floyd Landis has publicly apologized to people who donated hundreds of thousands of dollars to his legal defense after he failed a drug test during the 2006 Tour de France, only to admit later he was doping all along, and he promised to repay them.

Now he’s bound to by a court agreement.

FILE - In this July 23, 2006 file photo, Tour de France winner Floyd Landis of the U.S. holds his trophy on the podium after the final stage of the 93rd Tour de France cycling race in Paris. A French court on Thursday, Nov. 10, 2011 convicted American cyclist Floyd Landis in absentia for his role i

/ AP

FILE - In this July 23, 2006 file photo, Tour de France winner Floyd Landis of the U.S. holds his trophy on the podium after the final stage of the 93rd Tour de France cycling race in Paris. A French court on Thursday, Nov. 10, 2011 convicted American cyclist Floyd Landis in absentia for his role in hacking into the computers of a French doping lab. (AP Photo/Peter Dejong, File)

FILE - In this July 23, 2006 file photo, Tour de France winner Floyd Landis of the U.S. holds his trophy on the podium after the final stage of the 93rd Tour de France cycling race in Paris. A French court on Thursday, Nov. 10, 2011 convicted American cyclist Floyd Landis in absentia for his role in hacking into the computers of a French doping lab. (AP Photo/Peter Dejong, File) (/ AP)

Landis appeared in federal court in San Diego Friday morning and agreed to repay $478,354 to 1,756 donors. The agreement stipulates he has three years, “or until restitution is paid in full, whichever is less.”

The case is classified as a deferred prosecution, meaning Landis, 36, of Idyllwild could face one count of wire fraud — and possible prison time — should he violate terms of the agreement.

Friday’s hearing was the culmination of months of negotiations, following a grand jury investigation that Landis confirmed in April.

“I made a promise several years ago to pay people back, and I’m happy that there’s a way to do that without any questions as to whether it gets done properly or not,” Landis said outside the downtown courthouse, after the formality of being fingerprinted and booked.

Landis set up the Floyd Fairness Fund after his 2006 positive test and spent much of 2007 barnstorming across the country raising money at “town hall” meetings to bankroll his legal fees. A website also accepted donations through PayPal.

The actual amount Landis will repay likely won’t be $478,354. Donors can file a waiver excusing Landis of his financial responsibility, which Assistant U.S. Attorney Phil Halpern estimated would lower the amount closer to $400,000. In addition, a restitution schedule based on Landis’ post-tax income could limit his annual payments to as little as 5 percent, if he makes less than $50,000 a year.

“We do believe that there are outside sources of income,” Halpern said. “To the extent that there’s not, we can’t get blood from a stone. But to the extent that he does make money, we felt it vitally important that the victims of the crime are allowed to get their money back.”

The anti-doping community has criticized Halpern’s prosecution, in light of Landis’ detailed revelations about his performance-enhancing drug use and his cooperation with law enforcement, even reportedly wearing a wire to aid an investigation.

U.S. Anti-Doping Agency CEO Travis Tygart has met with Halpern to express his concern about the case but did not return calls for comment Friday.

“I take some umbrage with people saying, ‘You’re punishing the guy who came clean,’” Halpern said. “We’re not punishing the guy who came clean. We can’t excuse the fact that he stole hundreds of thousands of dollars.

“The message to athletes is if you do something wrong, don’t compound the problem by lying to people to get support for a misplaced defense.”