Solicitor General Donald B. Verrilli Jr. is stepping down later this month. (Haraz N. Ghanbari/AP)

U.S. Solicitor General Donald B. Verrilli Jr., who defended President Obama’s controversial health-care plan before the Supreme Court and successfully convinced a majority of the justices that same-sex couples should be allowed to get married no matter where they live, is stepping down June 24, U.S. officials announced Thursday.

Verrilli, the 46th solicitor general, had served as the country’s top appellate lawyer and advocate before the Supreme Court since 2011. He took over for Elena Kagan after her appointment as a justice. The 58-year-old spearheaded a number of high-profile cases, notably defending the Affordable Care Act in the King v. Burwell case and winning over a majority of the justices in Obergefell v. Hodges that the 14th Amendment required that same-sex marriages be recognized across the country. He had earlier won a case declaring unconstitutional a federal law defining marriage as between a man and a woman.

“For five years, Solicitor General Don Verrilli has fought in our nation’s highest court for a better future, winning landmark cases that moved America forward,” President Obama said in a statement. “Thanks to his efforts, 20 million more Americans now know the security of quality, affordable health care; we’re combatting discrimination so that more women and minorities can own their piece of the American Dream; we’ve reaffirmed our commitment to ensuring that immigrants are treated fairly; and our children will now grow up in a country where everyone has the freedom to marry the person they love.”

The president said he hoped Verrilli’s future included “a well-deserved vacation.” Verrilli informed the administration last year that he was ready to step down, but the White House asked him to stay for another term.

Verrilli will be replaced on an acting basis by Ian Gershengorn, the principal deputy solicitor general who had previously worked as a special assistant and counsel to the deputy attorney general in the Clinton administration. Attorney General Loretta E. Lynch said in a statement that Gershengorn played a “key role in some of our most high-profile cases, including as head of the Federal Programs Branch of the department’s Civil Division, where he personally argued in defense of the Affordable Care Act during district court challenges.”

“I have no doubt that Ian is well-equipped to build on departing Solicitor General Don Verrilli’s extraordinary record,” Lynch said. “I am confident that he will advance a trailblazing legacy of excellence and accomplishment.”

Before serving as solicitor general, Verrilli was an associate deputy attorney general and served in the Office of White House Counsel as deputy counsel to the president. An appellate lawyer who in private practice had argued numerous cases before the Supreme Court, he said in a 2012 interview that he left a job at Jenner & Block to serve in the federal government after Obama was elected.

“I essentially took the view that, once the president was elected in November 2008, I would be happy to do anything at the Department of Justice, including sweeping floors,” Verrilli said.

Verrilli at oral argument was not as smooth or polished as some of his predecessors; some predicted disaster for the Affordable Care Act when Verrilli’s initial presentation was completed. But instead, he prevailed on the most important Supreme Court challenges the Obama administration faced. In addition to the cases on gay marriage and health care, he convinced the Supreme Court to strike down several parts of a tough immigration law in Arizona.

“Don had one of the most successful tenures of any solicitor general in modern memory,” said Walter Dellinger, a longtime Supreme Court practitioner who served as acting solicitor general in the Clinton administration. “He twice defended the Affordable Care Act, he made the critical argument that the Defense of Marriage Act was unconstitutional, he successfully argued for the invalidity of state laws hostile to immigrants and helped preserve important tools against housing discrimination.”

Verrilli had a relatively high number of losses in less important and headline-grabbing cases, perhaps not surprising when defending a liberal administration in a court that grew increasingly conservative. Adam Winkler, a UCLA law professor, noted in a Daily Beast column June 2013 that the administration had, at that point, a mere 37 percent win percentage.

Winkler said in an interview Thursday that Verrilli throughout his tenure had “a tough time in many of the smaller cases at the Supreme Court,” but that was likely a reflection of the “ideological differences between the administration and the court’s majority.” When it mattered most, Winkler said, Verrilli often won.

“He should be judged by his biggest cases,” Winkler said. “By that standard, Donald Verrilli has had a remarkably successful tenure.”