Machen has been on the job for five years, and says he will leave his position on April 1. His top deputy, Vincent Cohen, Jr., will take over as acting U.S. attorney.
President Barack Obama appointed Machen in 2010. In a statement about the announcement, Attorney General Eric Holder called Machen "a forceful champion of justice on behalf of the American people." He also pointed to Machen's success in prosecuting terrorism, public corruption and violent crime.
Machen's decision to leave office comes amid an investigation of former D.C. Mayor Vincent Gray's 2010 campaign for office. Last year, a prosecutor in Machen's office said in court that Gray knew about a scheme to illegally fund his campaign.
On Monday afternoon, Gray's lawyer, Robert Bennett, told FOX 5, "My client is innocent of all allegations, and I will take the timing of the resignation, to call on the US Attorney's Office to close the investigation. Mayor Gray has suffered enough."
The Associated Press contributed to this report.