One of Attorney General Eric Holder's major projects has been working to shorten prison sentences for certain offenders. But now Holder is taking a step to spring a different kind of figure from the justice system: himself.

The White House announced Thursday that he'll be leaving his post as soon as a successor is confirmed. Holder has been serving since the start of the Obama administration—his five-and-a-half-year tenure at Main Justice is the longest for an AG since Janet Reno, who served for all of Bill Clinton's term, and fourth-longest all time. In February, The New Yorker's Jeffrey Toobin reported that Holder told him he'd step down sometime this year (though Justice weakly disputed the claim). But with Republicans threatening to capture the Senate in November, Holder was looking for an exit strategy; a source told NPR, which first reported the news, that he wanted to leave now rather than risk being locked in place for the rest of Obama's term if senators wouldn't confirm a replacement.

Even if the goal is for Holder to get out while he still can, his departure sets up a potentially contentious battle over the next attorney general. It seems unlikely that a successor could be confirmed before Election Day, setting up a fight during Congress's lame-duck session—a fight in which Republicans emboldened by Senate pick-ups might try to stop an Obama nominee. (It's an interesting contrast with Supreme Court Justice Ruth Bader Ginsburg, who recently cited the threat of a Republican Senate as the reason she had no intention of stepping down.)

The resignation of Secretary of Health and Human Services Kathleen Sebelius in April might offer a preview. In that case, a Cabinet secretary loathed by Republicans stepped down, and Obama nominated a trusted lieutenant who had already been confirmed by the Senate—making it harder for senators to balk and more likely that she'd be confirmed. In June, then-budget chief Sylvia Matthews Burwell was confirmed on a 78-17 vote. NPR reports that Solicitor General Donald Verrilli—best known for his stumbling but ultimately successful defense of the Affordable Care Act before the Supreme Court in 2012—is a leading candidate for the job, which would fit the pattern. Obama will speak Thursday afternoon, but the White House said he will not name a successor immediately.

Verrilli's defense of controversial Obama programs might make for some tense questions, but it's hard to imagine an attorney general having a more fraught relationship with Congress than Holder. Republicans began criticizing Holder even before Obama was inaugurated. The low point came in June 2012, when House Republicans held him in contempt of Congress for refusing to share documents related to Fast and Furious, a botched Keystone Kops-esque gun-running sting in Mexico connected to the death of a federal agent. The relationship hasn't improved much since. In a rare entertaining moment in a congressional hearing, Holder in April took a rhetorical potshot at GOP Representative Louie Gohmert for a past malapropism about asparagus. Holder also clashed with Congress over, and ultimately failed in, a quest to try terror suspects in civilian courts in the United States.

Meanwhile, he faced criticism from liberals and civil libertarians for enabling Obama's prosecution of the War on Terror. Among other cases, during his term as the nation's top lawman, the U.S. assassinated an American citizen in Yemen without a trial under questionable and not fully explained legal justifications. Holder also drew fire for failing to prosecute big banks more rigorously in the wake of the financial crisis, although in recent months, Justice has extracted a series of settlements from large institutions. Meanwhile, Holder outlasted a powerful roster of nemeses with the Obama administration, in part on the strength of his personal connection with the president, as Glenn Thrush reported in an excellent profile earlier this year.

But Holder leaves behind a historic record of speaking out and acting on issues of racial injustice. The first black attorney general has deep roots in the civil-rights movement, and where Obama has sometimes taken fire for refusing to speak more passionately or aggressively on race, Holder has had no such reservations. He called the United States "a nation of cowards" on racial questions.

Holder made it a priority early on to revitalize Justice's civil-rights division, which had been shaken by charges of politicization during the George W. Bush administration. His battle for sentencing reform for drug offenses is based in large part in major racial disparities in prison terms, and he's reportedly working on guidelines to prevent racial profiling. Holder loudly criticized the Supreme Court's decision to overturn a key section of the Voting Rights Act and steered the Justice Department to try to find creative ways to deploy what remains of that law to guarantee minorities the right to vote. He fought back against a spate of state-level laws that are ostensibly designed to fight voter fraud but in practice mostly reduce the non-white vote. And it was Holder, not Obama, who went to Ferguson, Missouri, as protests raged over Michael Brown's killing. Just Wednesday, Holder announced his backing for a suit against the state of New York for failing to provide adequate legal representation to poor defendants.

With Holder's departure, Obama will lose a close friend—an apparently rare breed—and an essential ally on issues close to the president's heart. Who Obama nominates to succeed him, and whether the nomination is successful, will offer some hint of how the president intends to close out his term in office. But the new attorney general is unlikely to have as eventful a term as Eric Holder.