As a professor at the University of Chicago Law School, Barack Obama was a favorite of his students, though his pedagogy was not that suggested by his background as a community activist, civil rights lawyer, and politician representing a largely minority district in the Illinois state legislature.

Teaching courses in racism and the law, voting rights, and due process—all topics fraught with political implications—he defied expectations by challenging the impacts of iconic liberal legal victories, like those ordering school desegregation and expanding voting rights.

“When I walked into class [on racism and the law] the first day I remember that we thought wewere going to get a very left-leaning  perspective on the law,” Jesse Ruiz told The Record, the law school’s alumni magazine, in 2009. “But he was very middle of the road. In his class we were very cognizant that we were dealing with a difficult topic, but what we really got out of that class was that he taught us to think like lawyers about those hard topics even when we had issues about those topics.”

So it should be no surprise that looking back on Obama’s eight years as lawyer-in-chief, the legacy that emerges is one of pragmatism that at times disappointed liberals as well as conservatives.

He transformed the face of the federal judiciary, both in terms of ideology and diversity, and in his first two years in office appointed two liberals to the Supreme Court.

He appeared to care most particularly about prison and criminal justice reform, commuting the sentences of a record number of prisoners and overseeing a dramatic change in prosecutors’ use of mandatory-minimum prison sentences. But his administration came to the table late, in his second term, limiting his accomplishments.

Stymied in his legislative agenda by Republicans, he added to an expanding view of presidential authority, setting a precedent that his successor, Donald Trump, may choose to emulate. In particular, he claimed sweeping powers to shield millions of illegal immigrants from deportation and allowing them to work. Much of that program was rejected by federal courts.

After initially expressing some reservations about same-sex marriage, Obama in 2011 made the heady and unusual decision that the Defense of Marriage Act was unconstitutional and should not be defended in federal court, leading eventually to the historic Supreme Court decision in 2015 making it legal nationwide. The Obama administration followed up by issuing a host of regulations aimed at easing life for gay couples. Later it told the states they were required to honor the bathroom and locker room preferences of transgender students. Obama successfully appointed 11 openly gay, lesbian, bisexual, or transgender judges, compared to one for his five predecessors combined.

Obama and Vice President Joe Biden were strong advocates for womens’ rights, wrangling with the Catholic Church and evangelicals over regulations requiring religious institutions to provide contraception coverage in their health plans and aggressively going after colleges or universities the administration deemed were too lax in protecting students who said they were victims of sexual assault.

Faced with the devastating ruling by the Supreme Court in 2012 striking down a key section of the Voting Rights Act, Obama’s Justice Department aggressively fought new restrictions on voting in Southern and other states, winning many on a case by case basis.

Under Attorney General Eric Holder, the Justice Department’s Civil Rights Division, which had been languishing and ineffective under President George W. Bush, was rejuvenated and became much more aggressive in taking abusive police departments to court, even before the wave of police killings of unarmed black men dominated the news. That gave the Justice Department credibility to step into new situations and calm protestors with assurances their grievance’s would be heard. The division’s massive report on wrongdoing by the tiny Ferguson, Missouri Police Department in 2015 vindicated long-standing grievances by blacks around the country that they were being targeted by racist cops and systemic discrimination.

“I think that he has really in many, many respects restored the importance for the rule of law and respect for the rule of law in our country,” said James M. Cole, Obama’s former deputy attorney general. “A lot of people thought he took the law into his own hands. But so many times he proposed legislation and Congress would do nothing with it, so the administration did what it was allowed to under the Constitution. He was very mindful, particularly having been a constitutional law professor, of the importance of the rule of law, the need to follow the law.’’

But on national security issues, many liberals and some conservatives say his legacy is a dangerous expansion of the executive’s authority to kill people overseas without judicial process, to conduct mass surveillance at home and abroad, and to charge people under the Espionage Act who leaked secrets to reporters, not to foreign governments. Those precedents may be exploited by his successor, they say.

"[President Barack Obama] has left a whole bunch of precedents for the next president and it looks like the next president will be more hawkishly inclined than Obama to useunilateral war powers." Jack Goldsmith, Harvard Law Professor

Of particular concern was thetargeted killing of Anwar Al-Awlaki, an American citizen, in a drone strike in Yemen in 2011.

“I think the administration has been sensitive to civil liberties concerns in many different areas,” says Jameel Jaffer, a law professor at Columbia University and the author of a new book on Obama’s drone program, “The Drone Memos.” But not, Jaffer said, on national security issues.

“We now have a bureaucratic and legal infrastructure that allows the president to order the killing of anyone deemed to be associated with Al-Qaeda or an affiliated force without ever presenting to any court evidence to justify the killing. It’s a very dangerous thing.”

The legal legacy of any president is measured foremost by any appointments to the Supreme Court and the rest of the federal judiciary, because they have lifetime tenure.

His first Supreme Court nominee, Sonia Sotomayor, has been a fiery and articulate champion of minorities and the oppressed, and with her Puerto Rican heritage, a beloved role model for Hispanics.

His second, Elena Kagan, represented a more pragmatic effort to nominate someone from the legal establishment (she taught law with Obama at Chicago before moving to Harvard University) who, though still liberal, could reach out to and negotiate with more conservative justices like Anthony Kennedy.

His unsuccessful nomination of middle-of-the-road Democrat Merrick Garland was partly a bow to the political realities of the Senate, but was also revealing in representing Obama’s own cautious approach to the law. Because Garland was picked to replace ultra-conservative Antonin Scalia, the choice had the potential to be the most impactful on the court in a generation.

Taken together, his three nominations, of a fiery liberal, a cautious liberal, and a moderate Democrat, perfectly represent his pragmatic approach to the law.

In the lower courts, Obama achieved dramatic change, setting records for diversity and changing the ideological balance of a majority of the federal appeals courts.

Over 40 percent of his judges are women, twice as many as President George W. Bush and over a third more than President Bill Clinton. Obama also appointed twice as many minority judges to the bench proportionately than Bush—more than one out of three and topped Clinton in this regard by 50 percent.

But the Obama White House gota painfully slow start to judicial nominations, and in those people  it did manage to nominate, initially bowed to Republican opposition by nominating middle-of-the-roaders rather than out-and-out liberals.

White House insiders said later that the administration was preoccupied in its first two years with the Sotomayor and Kagan nominations as well as by the emphasis on finding diverse candidates. But critics said lower court judges were just not a priority at the White House until Kathryn Ruemmler took over as White House Counsel in June 2011.

Of course, implacable Republican opposition to Obama nominees in the Senate also hampered the effort. When Democrats controlled the Senate, Judiciary Committee Chairman Patrick Leahy, D-Vt., allowed any Republican to block a nominee from their home state, and for the last two years, Chairman Chuck Grassley, R-Iowa, put the brakes on further.

By the time of the elections inNovember, there were 108 judicial vacancies, half of them without nominations from the White House.

Still, judges appointed by Obama now make up a third of the appeals court judges across the country. When Obama took office, only three of the 13 appeals courts had a majority of judges nominated by Democrats. Late in his last term, Democratic nominees controlled nine.

In particular, the confirmation of three Obama nominees in 2013 to the D.C. Circuit Court of Appeals, which is often the last word on regulatory issues, gave Democrats a majority on  the few hot button cases that tend to divide that court along party lines. Obama lost some key environmental regulation decisions there before getting his nominees in place.

If the judiciary is a president’s greatest legal responsibility, the criminal justice system that feeds it and houses its prisoners may be the second.

Obama named Eric Holder Jr., an experienced prosecutor and liberal African-American passionate about racial justice, as attorney general, raising expectations of major change. But in the first term Obama’s White House Chief of Staff Rahm Emanuel kept a tight lid on new initiatives by Holder, who was initially seen in the White House as a political loose cannon. Holder, meanwhile, was consumed by battles with Congress, including the controversy over a failed gun trafficking sting that allowed illegal guns to flow freely into criminal hands. The controversies seemed to absorb all his attention, insiders say. Some liberal advocates were deeply disappointed by his performance.

But with political restraintsdiminished after Obama’s reelection in 2012, Holder, who had been expected to step down, instead sought and received from Obama backing for a more activist agenda.

"I think the administration has been sensitive to civil liberties concerns in many different areas." Jameel Jaffer, Law Professor at Columbia University

The following summer Holder announced to the American Bar Association in San Francisco that he had directed his prosecutors not to seek mandatory minimum prison sentences for low level, nonviolent drug offenders. It was a serious attempt to cut back on the burgeoning prison population and particularly the number of African-Americans in prison.

In 2014 the Justice Department unveiled the most ambitious federal clemency program in 40 years, inviting an estimated 7,000 prisoners serving long prison sentences for crimes whose punishments had since been reduced to apply for presidential mercy.

By the election Obama had already granted more commutations than the previous 11 presidents combined. But because of bureaucratic delays in processing applications, the number was far less than expected. Obama was less inclined than many of his recent predecessors to issue pardons.

In 2016, the Justice Department announced it would phase out the use of private prisons, where some of the worst abuses had occurred.

But the administration failed to achieve its primary goal: broad legislative reform of sentencing and parole guidelines, despite bipartisan support for the concept in both the House and Senate. Wrangling over the legislation brought it too close to the flame of the 2016 presidential election.

Faced with the reality of wars in Afghanistan and Iraq and terrorism spreading around the globe, Obama the president proved more conservative on national security law than Obama the candidate, and has earned enduring criticism.

Determined to get most U.S. troops out of those countries, he turned to a model the administration called “light-footprint warfare,” relying on drones and other airstrikes that put few American soldiers in jeopardy but often led to innocent civilians being killed.

Much of the criticism has focused on Obama’s flexible legal interpretations of the congressional authorization for the use of military force against Al-Qaeda after the 9/11 attacks, as well as earlier war power acts and the constitution itself.

“His most consequential legal legacy [in national security] was extending the 2001 authorization for use of military force to include the Islamic State, which has expanded the war in ways that many people in his defense department think is going to take decades to finish,” says Jack Goldsmith, a Harvard Law professor who worked on these issues in the Bush administration after 9/11. “When we are fighting this war against ISIS in 15 years we will look back on this as his most significant legacy.”

Hillary Clinton, while secretary of state under Obama, pushed for a more aggressive foreign policy than Obama was comfortable with, particularly in Syria.“He has left a whole bunch of precedents for the next president and it looks like the next president will be more hawkishly inclined than Obama to use unilateral war powers,” Goldsmith said.

Jaffer, formerly a top national security advocate for the ACLU, says that Obama ran roughshod over civil liberties in some other areas as well, notably surveillance and freedom of the press.

“Leaks are another problematic aspect of President Obama’s legacy,” Jaffer says. “This administration has prosecuted more people under the Espionage Act than all previous administrations combined. More troubling is that he has collapsed the distinction between individuals who disclose information to foreign intelligence services and individuals who disclose information in the public interest to the press.”

Obama also earned criticism from the left and some on the right for continuing mass surveillance of telephone calls and emails and other communications. While the public outcry after Eric Snowden released details of the program led Congress to enact some modest restraints, the Obama administration for the most part defended the programs first initiated by his predecessor.

How did a liberal legal activist end up as a hawk on national security legal strategy?

“I started every morning with a threat briefing finding out about all the people who are trying to kill us, and there were a lot,” Cole says. “We in the government have this responsibility to make sure we are keeping the country safe, but we have to balance that by protecting our civil liberties. There will always be criticism on how we maintain that balance.”

Jaffer says one explanation is that there wasn’t a political constituency for reform of national security policy as there was for gay rights or racial justice. But what happened is not just Obama’s legacy, but that of the country as a whole, he argues.

The terrible sense of responsibility that any president feels is part of the explanation, Jaffer says, but “it doesn’t explain why we as a country did what we did.” Neither the courts nor the Congress fulfilled their roles as a watchdog on the executive in this area, he says. And when Obama did try and do “the right thing,” such as prosecuting 9/11 defendants in civilian courts and closing Guantanamo, he got slapped down by Congress, Jaffer says.

“Overall, I think he’s been a great president in many different ways. I feel confident history will see it that way,” Jaffer says. “I just hope that won’t obscure what I think he has done to the international human rights framework and even to the Constitution by creating very broad policies related to targeted killings.”