Lance Armstrong agreed on Thursday to pay $5 million to settle claims that he defrauded the federal government by using performance-enhancing drugs when the United States Postal Service sponsored his cycling team.

The settlement ended years of legal wrangling between Armstrong and the government over whether the Postal Service had actually sustained harm because of Armstrong’s doping.

After years of vehement denials, Armstrong admitted in 2013 that he had used banned substances while winning a record seven Tour de France titles from 1999 to 2005. He wore a Postal Service jersey during the first six of those victories, but he was stripped of all his Tour titles in 2012 after an investigation by the United States Anti-Doping Agency determined that he and many of his teammates had been doping.

“We’ve had exactly the same view of this case forever, which was that it was a bogus case because the Postal Service was never harmed,” Elliot Peters, Armstrong’s lead lawyer, said in a telephone interview.