U.S. Attorney Ronald C. Machen Jr. speaks during a 2013 event in Northeast Washington. Machen announced Monday he will step down and return to private practice. (Andre Chung/For The Washington Post)

U.S. Attorney Ronald C. Machen Jr. announced Monday that he will step down April 1 and return to private practice, ending a tenure that has made him the longest-serving chief federal prosecutor for the District of Columbia in nearly four decades.

Machen oversaw a steady expansion of the U.S. Attorney’s Office’s reach into national security and financial fraud cases in his five years in office, and he devoted significant new resources to pursuing cold cases and potential wrongful convictions.

But his time as top prosecutor in the nation’s capital was dominated by the aggressive pursuit of local public corruption — leading to the convictions of dozens of government officials and employees, including three former D.C. Council members. Still, his legacy remains uncertain, as his top target, former mayor Vincent C. Gray (D), remains uncharged after a four-year-long investigation.

As television cameras rolled, Machen has declared Gray’s 2010 mayoral bid corrupt, while prosecutors publicly accused Gray of having detailed knowledge of a “shadow campaign” to illegally funnel $660,000 into his get-out-the-vote effort. Gray has called the allegations “lies.”

Ronald Machen, center, is seen in 2013 during an event in Northeast Washington. (Andre Chung/For The Washington Post)

Unless Gray is charged in the next two weeks, Machen will leave office with the case unresolved.

Council member Mary M. Cheh (D-Ward 3) said whatever the outcome for Gray, Machen’s record will be “forever marred” by his handling of the mayor. Cheh was among the first elected officials who called on Gray to resign because of the investigation.

“It’s one thing to have somebody under investigation and pursue matters diligently, but it’s quite another, I think, to allow a cloud like that to exist for years,” said Cheh, who is also a professor of criminal and constitutional law at George Washington University.

Current and former Justice Department officials and prosecutors said they expected little disruption in the investigation because Machen’s top assistant, Vincent H. Cohen Jr., has served as the point person in coordinating the probe and will take over as acting U.S. attorney.

Robert S. Bennett, Gray’s attorney, declined to comment on Machen’s resignation, but he reiterated Monday that he thinks the investigation should be ended without charges against his client.

“I am hopeful that this investigation will finally be closed because the mayor is innocent of all allegations of wrongdoing,” Bennett said. Many Gray supporters have blamed the investigation for the former mayor’s April 1 loss in the Democratic primary to rival Muriel E. Bowser, who went on the claim the mayoralty.

Neil H. MacBride, U.S. attorney for the Eastern District of Virginia from 2009 to 2013, said no one should draw conclusions about the effect of Machen’s departure on the Gray investigation, or any other pending case, particularly because his top deputy remains in charge.

“In offices like D.C. . . . the sun truly never sets on the pipeline of ongoing investigations or charged cases,” MacBride said. MacBride recalled that on his first day in office, a memo regarding the prosecution of Sept. 11 mastermind Khalid Sheik Mohammed required immediate attention. While MacBride was preparing to leave his post, his office had just charged National Security Agency contractor Edward Snowden, and the investigation into then-Virginia Gov. Robert F. McDonnell (R) was still underway.

In an interview, Machen, 45, proudly cited accomplishments while heading one of the of the largest U.S. attorney’s offices in the country, with more than 300 attorneys. He defended his office’s actions in the Gray matter and said that the timing of his announcement was driven solely by “personal circumstances.”

“People can say what they want to say, but it would be a mistake to assume that our office is going to back down on public corruption because I’m leaving,” Machen said. “Personal circumstances are driving my departure, not anything related to the investigation of the 2010 mayoral race.”

Associates said Machen, who is married and has three sons, including two who are school-age, is likely to return to his old law firm, WilmerHale, where, they said, compensation exceeding $1 million is not unusual. By comparison, the U.S. attorney for the District earns $158,700 a year, less than first-year associates at major firms.

“I actually thought I was going to leave over a year ago, but the timeline kept getting extended. I then thought I would leave at the end of 2014, and that got extended,” Machen said. “It’s really not fair to my family. . . . I’ve broken promises to them for a while, and I need to start keeping them.”

Machen was nominated by President Obama and sworn in to the post in February 2010. He surprised some by continuing for a second term. By April, Machen will have served longer as U.S. attorney in the District than anyone since 1979, when Earl J. Silbert, one of the original prosecutors of the Watergate scandal, stepped down.

Machen’s move coincides with U.S. Attorney General Eric H. Holder Jr.’s expected departure this week, pending Senate confirmation of his successor, Loretta B. Lynch, but several officials said the timing was unrelated.

“Ron has never been deterred by a difficult challenge nor slowed in his pursuit of a safer, stronger Washington,” Holder, a longtime mentor who was the District’s U.S. attorney who first hired Machen into the office in 1997, said in a written statement. “I see in him now the exceptional qualities that I saw in him then: unassailable integrity, relentless determination, and a passion for law and justice.”

Machen played wide receiver as a walk-on at Stanford University. Upon graduation, he contemplated attending the University of Michigan’s law school on scholarship. But his father told him that he would be settling if he went to the prestigious Big Ten university, so he went to Harvard instead.

Machen worked from 1997 to 2001 as a federal prosecutor in the District, the only federal office that prosecutes local and federal crimes. He went on to join and made partner at the law firm now called WilmerHale, and he donated more than $4,000 to Obama’s campaigns and helped vet potential vice presidential candidates in 2008.

Machen’s office pointed to its growing portfolio of national security and public corruption cases as top successes, as well as prosecutions of scores of violent offenders and the recovery of more than $2 billion from financial firms in fraud and money laundering investigations.

For example, the office was tapped to lead the pending federal prosecution of Ahmed Abu Khattala, suspected ringleader of the 2012 attacks in Benghazi, Libya, that killed a U.S. ambassador and three other Americans.

District prosecutors also secured the conviction of four guards at the former Blackwater Worldwide this past fall in the September 2007 shootings of 31 unarmed Iraqis in Baghdad’s Nisour Square; and of Julian Zapata Espinoza, the Mexican drug cartel commander who pleaded guilty in 2013 to ordering an ambush that killed Jaime Zapata, a U.S. immigration agent, in Mexico.

But controversy followed the office’s handling of other security-related cases, including the prosecution of Donald Sachtleben, a former FBI bomb technician and contractor who in 2013 admitted leaking information about a disrupted terrorist bomb plot to the Associated Press.

After that case — in which investigators subpoenaed two months of call records of 20 lines used by the AP — and other cases, involving reporters for the New York Times, CBS and Fox News, Holder and Obama publicly announced a review of Justice Department guidelines for investigations that involve journalists, and Holder called the handling of the Fox case his biggest regret.

Among D.C. Superior Court cases, highlights under Machen included the 2010 trial and conviction of Ingmar Guandique in the death of federal intern Chandra Levy. That case is being heard on appeal.

Most recently, he oversaw the plea deal of a Modern Orthodox rabbi, Barry Freundel, who pleaded guilty to 52 counts of voyeurism last month. Freundel was charged with secretly videotaping nude women as they prepared for a ritual bath.

Machen also oversaw the convictions of the five men charged with the 2010 South Capitol Street shootings that left four people dead and six others injured. Six men were convicted in those shootings.

Machen’s office has also led community outreach and youth engagement initiatives.

He created the new conviction integrity unit in response to a string of recent DNA exonerations, involving flawed FBI forensic work in decades-old cases. His office also cast light on what it called mistakes by the District’s DNA lab and moved to clean up cases tainted by an FBI agent working with a D.C. police narcotics task force who allegedly tampered with evidence.

Carol D. Leonnig contributed to this report.