For the rest of his life, Barack Obama will be able to walk into arenas and get a standing ovation and requests for hugs, handshakes and selfies.

A generation of Democrats will remember the sense of revolution that seized America in 2008 when he won the presidency.

They will describe to their children the sheer hope they felt when the Bush era came to an end.

He won his place in the history books by showing that a black man could win the presidency of a country still struggling with the legacy of slavery, ethnic persecution and segregation.

But right now, as the Obama era enters its final hours, millions of voters will look at the prospect of Donald Trump’s arrival in the White House with nothing but dread.

Is this the ultimate verdict on Obama’s own legacy after two terms in the Oval Office?

The nation has replaced this erudite champion of liberal values with a billionaire who proposed banning the entry of Muslims to the US and boasted his fame allowed him to “do anything” to women.

The Obama family in May 2008, when the future president was still in pursuit of the Democratic nomination

Cornel West, one of the United States’ most celebrated black scholars, summed up the situation facing the country before launching into a withering assessment of Obama.

He wrote: “Eight years ago the world was on the brink of a grand celebration: the inauguration of a brilliant and charismatic black president of the United States of America. Today we are on the edge of an abyss: the installation of a mendacious and cathartic white president who will replace him.”

The sight of Trump boarding Air Force One may well make Obama queasy but for decades to come he will replay crisis moments from his time as Commander in Chief and wonder if he missed precious opportunities to build a better world, or at least hold back evil.

Fighters from the so-called Islamic State group parade in a commandeered Iraqi security forces armored vehicle in Mosul

Obama won early prominence as the first black editor of the Harvard Law Review but the restraint with which he has exercised American military might suggests he lives by a dictum drilled into medical students: First, do no harm.

On his watch, the so-called Islamic State emerged as a terrorist force and took hold of swathes of Iraq and Syria as the excitement of the Arab Spring was replaced by a new chapter of terror in the Middle East. Meanwhile, Russia annexed Crimea and used its forces to crush the uprising in Syria and turn the regime into a puppet government.

The case against Obama is that he allowed his country’s foes and rivals to believe an America battered by long wars in Iraq and Afghanistan was in retreat. Vladimir Putin sensed a power vacuum and snatched the opportunity to showcase Russia’s military strength.

Russian President Vladimir Putin in Yalta, Crimea

Obama’s foreign policy doctrine has been summed up in four words: “Don’t Do Stupid Stuff” (with “stuff” sometimes replaced with something stronger).

Sending battalions of troops back into Iraq to fight IS or stationing forces in Ukraine would look decidedly “stupid” to legions of Americans who fully understand the true cost of war because someone they love was killed or injured during the conflicts of the Bush era.

Pro-Russian soldiers march near a Ukrainian army base in Perevalne, Crimea

But future generations of students will write essays on whether US turned inward, shied away from threats and let blazing crises rip through entire regions.

For a brief period during the so-called Arab Spring at the start of this decade there were hopes that the Middle East would experience the type of democratic transformation that swept through former Communist Europe after the fall of the Berlin Wall.

But instead we saw the military overthrow a Government in Egypt, extremists slaughter tourists in Tunisia and Turkey lurch towards authoritarianism.

The 2011 Nato bombing campaign in Libya gave anti-Gaddafi rebels the upper hand but the country dissolved into chaos as militias competed for control of oil-rich territory. Did we need another case study in what happens if there isn’t a post-conflict plan for peace?

People jump out of a boat right before it overturns off the Libyan coast

Extremists set up camp in Libya, the US ambassador and his colleagues were murdered when a Benghazi compound was attacked and the country has become a staging post for thousands of migrants who make the treacherous journey across the Mediterranean.

The greatest humanitarian scandal that overlaps with Obama’s tenure as president is the carnage in Syria.

Obama sent out the message that the trigger for US military intervention would be the use of chemical weapons. But when this red line was allegedly crossed the world’s last true superpower stepped back.

Russia seized the opportunity to take the lead and gave decisive help to the Assad regime, blitzing rebel groups in a ferocious display of firepower.

With Russian help, Syrian pro-Government forces have recaptured Aleppo

Obama leaves office with anxiety high in eastern Europe that Russian forces will undermine democratic governments and stamp on leaders who want to strengthen bonds with Nato and the EU. A new era of cyberwarfare has begun following the hacking of US parties during the presidential elections and there is open talk of a new Cold War.

Obama cannot be blamed for Putin’s decision to embrace an autocratic form of aggressive nationalism, just as the United States could not flick a switch and stop radicals in the Middle East growing intoxicated with increasingly barbaric ideology.

Putin and Obama at the UN Conference on Climate Change in Paris

But he will ask himself whether he could have done more to stop the slaughter of innocent Syrians which sent waves of refugees on panicked journeys into the unknown.

He boasts of having “shut down Iran’s nuclear weapons program without firing a shot” and if the deal with the former pariah state survives the Trump era it may be recorded as a bona fide diplomatic masterstroke.

Likewise, he was prepared to risk the anger of US Cubans who fled the Castro regime when he visited the island nation last year and took important steps to normalise relations. If Cuba makes a peaceful transition to democracy and fulfils its massive economic potential Obama will deserve credit for taking a politically courageous first step.

It was unrealistic to think a President could neutralise the world’s most toxic conflicts but think back to the sheer hope that Obama inspired in the wake of his election. This is the President who went to Cairo in 2009 to, in his own words “seek a new beginning between the United States and Muslims around the world”.

The Bushes and the Obamas after the election in November 2008

This is the man who won the Nobel Peace Prize that year for his “extraordinary efforts to strengthen international diplomacy and cooperation between peoples”.

He takes pride in the killing of Osama bin Laden – an operation which showed the US boasts superb intelligence, unrivalled military expertise and a readiness to strike at its enemies. But his administration’s reliance on drone strikes remains controversial.

Micah Zenko of the Council on Foreign Relations noted in the New York Times: “Obama’s embrace and vast expansion of drone strikes against militants and terrorists will be an enduring foreign policy legacy. Whereas President George W Bush authorized approximately 50 drone strikes that killed 296 terrorists and 195 civilians in Yemen, Pakistan and Somalia, Obama has authorized 506 strikes that have killed 3,040 terrorists and 391 civilians.”

When one considers the human suffering and political repercussions that followed the killing of 13 people in Northern Ireland on Bloody Sunday in 1972 it is sobering to think of the grievance and anger that will burn for years in the families of innocent people who died in these attacks.

John Kerry warned Israel's democratic future is at stake

US Secretary of State John Kerry last month gave an earnest warning that the vision of a “two-state” solution in which an independent Palestine exists alongside a secure Israel is in “jeopardy”. His sounding of the alarm bell was a reminder of how little progress has been made.

Even away from crisis zones, Obama’s international legacy is fragile.

Obama met then-PM Gordon Brown at Downing St during the 2008 campaign

His warning last year that if the UK voted for Brexit it would be at the “back of the queue” when it came to striking a trade deal backfired mightily.

Similarly, his epic Trans-Pacific Partnership trade deal took seven years to negotiate and was a key part of his “pivot to Asia” but Trump has pledged to reject it on his first day in office. The word “dead” is now routinely used to describe the Transatlantic Trade and Investment Partnership in which he invested such ambition.

Michelle Obama at the Qinshihuang Terracotta Warriors and Horses Museum in 2014. The Obama administration made a determined effort to focus attention and diplomatic energy on Asia

Obama’s work to protect the environment could also be reversed. He secured the ratification of the landmark Paris climate change agreement but Trump has pledged to “unleash America’s $50 trillion in untapped shale, oil, and natural gas reserves, plus hundreds of years in clean coal reserves” and “eliminate all barriers to responsible energy production”.

In May, Trump pledged to “cancel the Paris agreement” but in November he said he had an “open mind”. Obama will hope his successor decides this historic deal is one to keep.

On the home front, Obama points to the economy with pride. He was elected at a time of financial turmoil but he takes credit for saving the US car industry and working to “unleash the longest stretch of job creation in our history”.

The introduction of so-called “Obamacare” extended health insurance coverage to 20 million more Americans. Government figures show the percent of the population without health insurance fell “from 16% in 2010 to 8.9% in January-June 2016”.

The passing the Affordable Care Act is considered one of the top achievements of Barack Obama and Vice President Joe Biden's time in office

Laura Bassett, writing in the Huffington Post, described the impact of this landmark legislation for women.

She said: “Obama’s signature health care law saved women $1.4bn on birth control pills alone in 2013, the year after it went into effect. More than 55 million women now get their contraception and well-woman visits for free, and unintended pregnancy in the United States is at a 30-year low.”

Data from the US Department of Health and Human Services about the lack of health insurance coverage

But is Obamacare about to vanish? Trump this week described it as “catastrophic” and said it would be repealed and replaced “very quickly or simultaneously”.

Obama is without question the most effective orator of his generation but one of the sadnesses of his presidency is that on so many occasions he had to find words to comfort those who were heartbroken and traumatised by yet another mass shooting.

Obama speaks at a service honouring the life of Reverend Clementa Pinckney, one of nine people killed in the shooting at Emanuel AME Church in Charleston

He leaves office with swathes of the electorate concerned not just at how lone nuts or gang members abuse firearms but about the police’s readiness to shoot people. The Black Lives Matter campaign has revealed the depth of distrust and fear with which many African-Americans view the police.

The Occupy Wall St movement which took up residence in Zuccotti Park in 2011 was an expression of another strain of anger, this time focused at the rampant inequality in US society.

Emmanuel Saez of the Washington Centre for Equitable Growth wrote that the “share of income going to the top 1% of families – those earning on average about $1.4m a year – increased to 22% in 2015”.

Was anger at this failure to share wealth the fuel that powered Trump’s journey to victory?

Trump managed to get voters in the 'rust belt' to back him and reject the Democrats

Historian Kimberly Phillips-Fein told New York magazine she expects scholars of the future to “focus on the rising inequality in the American economy during the Obama years, the deepening precariousness experienced by people who once anticipated a greater level of security and prosperity, and on the poisonous impact this has on the entire American political system.”

She added: “The crash of 2008 and its aftermath may come to be seen as a moment when greater reform was possible... This didn’t happen, and it’s the great missed opportunity of the Obama presidency.”

Trump and Obama sat down together days after the election

Obama’s opportunities for great reforms were constrained by economic crisis, the challenge of bring troops home from Iraq and Afghanistan and a gridlocked Congress. But he did not miss the chance to articulate a vision for an increasingly diverse America which is energised and united by it founding values. – and there is a crumb of comfort in that Hillary Clinton beat Trump in the popular vote by 48.2% to 46.1%.

A core accomplishment is that he leaves office untainted by political or personal scandal. Presidents often step down with even their core supporters embarrassed or angry about some of the decisions of the person they helped get elected.

Obama and his wife Michelle bump fists at an election night rally in June 2008 in St Paul, Minnesota. He clinched the Democratic presidential nomination on the back of the primaries in South Dakota and Montana

Few of those who embraced Obama when he was a young Illinois senator will have significant regrets. They might wish he had been bolder, reached further and fought harder but when they watch Obama, Michelle and their family leave the White House millions of those he inspired will feel pride. He left them wanting more.