Before he took office in 2008, Barack Obama vowed to end America’s grueling conflicts in Iraq and Afghanistan. During his second term, he pledged to take the country off what he called a permanent war footing.

“Our systematic effort to dismantle terrorist organizations must continue,” he said in May 2013. “But this war, like all wars, must end. That’s what history advises. It’s what our democracy demands.”

ADVERTISEMENT

But Obama leaves a very different legacy as he prepares to hand his commander-in-chief responsibilities to Donald Trump.

U.S. military forces have been at war for all eight years of Obama’s tenure, the first two-term president with that distinction. He launched airstrikes or military raids in at least seven countries: Afghanistan, Iraq, Syria, Libya, Yemen, Somalia and Pakistan.

Yet the U.S. faces more threats in more places than at any time since the Cold War, according to U.S. intelligence. For the first time in decades, there is at least the potential of an armed clash with America’s largest adversaries, Russia and China.

Obama slashed the number of U.S. troops in war zones from 150,000 to 14,000, and stopped the flow of American soldiers coming home in body bags. He also used diplomacy, not war, to defuse a tense nuclear standoff with Iran.

But he vastly expanded the role of elite commando units and the use of new technology, including armed drones and cyber weapons.

“The whole concept of war has changed under Obama,” said Jon Alterman, Middle East specialist at the Center for Strategic and International Studies, a nonprofit think tank in Washington.

Obama “got the country out of ‘war,’ at least as we used to see it,” Alterman said. “We’re now wrapped up in all these different conflicts, at a low level and with no end in sight.”

“ The whole concept of war has changed under Obama. ” — Jon Alterman, Middle East specialist at the Center for Strategic and International Studies Share this quote

A Reaper drone prepares for a mission in Afghanistan. Obama expanded the use of new technology, including armed drones and cyber weapons. (Rick Loomis / Los Angeles Times)

The administration built secret drone bases and other facilities in Africa and the Middle East, and added troops and warships in the western Pacific. It also moved troops and equipment to eastern Europe to counter a resurgent Russia.

Along the way, Obama sometimes quarreled with his top military advisors. After they left the Pentagon, Obama’s first three secretaries of Defense — Robert M. Gates, Leon E. Panetta and Chuck Hagel — accused the Obama White House of micromanaging the military.

Obama’s political rise famously began with a speech he gave in Chicago in October 2002, when he announced he was “opposed to dumb wars,” referring to the planned invasion of Iraq by the George W. Bush administration.

ADVERTISEMENT

But as president, Obama found himself caught in the fierce cross currents of the so-called Arab Spring uprisings that roiled much of the Middle East and North Africa in 2011, leading to harsh crackdowns across the region. Only one country, Tunisia, ultimately saw a transition to democracy.

He reluctantly approved a NATO air campaign in Libya initially aimed at preventing massacres of civilians by strongman Moammar Kadafi.

Determined to avoid the kind of nation building that pulled the U.S. into Iraq’s civil war, he withdrew after Kadafi was killed — only to see the oil-rich country collapse in conflict and become a magnet for terrorist groups.

The danger was clear after members of the Islamic militant group Ansar al Sharia stormed a U.S. diplomatic compound and nearby CIA base in Benghazi, in eastern Libya, in September 2012, killing U.S. Ambassador J. Christopher Stevens and three other Americans.

The messy aftermath in Libya made Obama realize the limitations of military power in achieving U.S. goals, and that shaped the rest of his presidency, said Benjamin Rhodes, his deputy national security advisor.

“We can destroy things,” Rhodes said. “He does not believe we can shape the trajectory of the internal politics of another country or the building of a new society.”

Obama was guided by caution after the Libya experience — with mixed results.

He kept U.S. ground forces out of Syria’s bloody civil war but could not stop a conflict now in its sixth tragic year — and saw America’s influence weaken as Russia and Iran filled the gap.

In January 2014, Obama mocked the emergence of Islamic State in Syria as a minor threat compared with Al Qaeda. “If a JV team puts on Lakers uniforms, that doesn’t make them Kobe Bryant,” he told the New Yorker.

But that summer, with the black-garbed Sunni militants threatening Baghdad, Obama was forced to rush U.S. troops back to Iraq and order a flurry of airstrikes to block further advances by the group.

He leaves office with 5,262 U.S. troops in Iraq and 503 in Syria and a relentless air war that has helped push the militants out of key cities and towns, and crippled their ability to produce or sell oil.

U.S. soldiers keep watch in the southern desert of Iraq before a September 2010 troop drawdown. Obama leaves office with 5,262 military personnel in the country. (Carolyn Cole / Los Angeles Times)

Yet Islamic State still controls large parts of both countries. It remains larger and more powerful than Al Qaeda ever was, luring an an estimated 35,000 foreign fighters and followers to its self-declared caliphate and sponsoring or inspiring deadly attacks around the globe.

In a speech on Dec. 6 at MacDill Air Force Base in Florida, Obama all but conceded that he was unable to get America out of the foreign wars, large and small, that grew out of the Sept. 11, 2001, attacks.

“We know that in some form this violent extremism will be with us for years to come,” Obama said. “In too many parts of the world, especially in the Middle East, there has been a breakdown of order that's been building for decades, and it’s unleashed forces that are going to take a generation to resolve.”

“ We know that in some form this violent extremism will be with us for years to come. ” — President Barack Obama Share this quote

Obama speaks at MacDill Air Force Base in Florida on Dec. 6, 2016.

Obama considers his diplomatic achievements — particularly the nuclear deal with Iran, the Paris agreement to fight climate change and a restoration of diplomatic relations with Cuba — to be his primary foreign policy legacy.

Diplomacy has “helped keep us safe and helped keep our troops safe,” he said at MacDill.

Yet those achievements may not last. Trump has threatened to dismantle or renegotiate them all.

Obama’s aides are frustrated that the president doesn’t get credit for keeping U.S. troops out of another major ground war.

“It’s hard for people to remember, but when we came into office we were losing 100 people a month, spending $10 billion a month — an unsustainable allocation of resources and an incredible burden on our military,” Rhodes said.

Spending and casualties both have fallen sharply. The Pentagon has spent a total of $10 billion in the 30 months since it went to war against Islamic State in mid-2014, and the militants have killed only five American service members in Iraq and Syria since that time.

Coalition forces assemble at the Qayyarah Airfield West in Iraq in November to retake Mosul from Islamic State. At right, a soldier keeps watch over the airfield. (Carolyn Cole / Los Angeles Times) Coalition forces assemble at the Qayyarah Airfield West in Iraq in November to retake Mosul from Islamic State. Below, a soldier keeps watch over the airfield.. (Carolyn Cole / Los Angeles Times)

Rhodes argued that Obama also made key decisions that kept the country from being pulled into other conflicts.

“There are any number of decisions we could have made that would have led to war,” he said. “It’s hard for people to sometimes visualize the counterfactual, but there are decisions that a president makes every week about whether to escalate.”

“It’s a choice not to escalate,” he added.

Obama’s legacy as a peacemaker seemed assured in his first year in office, when he was awarded the Nobel Peace Prize, largely for the promises he had made to reduce the threat of nuclear war.

But the award came at an awkward time. Obama’s inner circle knew he planned to send 30,000 more U.S. troops to Afghanistan to try to stabilize the country before withdrawing U.S. ground forces altogether.

Obama’s acceptance speech in Oslo reflected his ambivalence about lauding the ideals of peace while sending Americans to kill and be killed in distant lands.

“Negotiations cannot convince Al Qaeda’s leaders to lay down their arms,” he said. “To say that force may sometimes be necessary is not a call to cynicism. It is a recognition of history, the imperfections of man and the limits of reason.”

Gates said Obama also was ambivalent about sending more troops to Afghanistan in 2009. Obama was skeptical “if not outright convinced it would fail,” Gates wrote in his 2014 book, “Duty: Memoirs of a Secretary at War.”

Obama had his own priority, Gates wrote. “For him, it’s all about getting out.”

He never quite succeeded. Obama leaves office with 8,400 troops still in Afghanistan. Their mission is to support a weak central government that is still battling the Taliban — 15 years after a U.S. invasion forced the militants from power.

“ To say that force may sometimes be necessary is not a call to cynicism. It is a recognition of history, the imperfections of man and the limits of reason. ” — President Barack Obama in his Nobel acceptance speech Share this quote

In his first term, the Obama team tried to turn attention away from the Middle East with a strategic pivot toward the Asia Pacific region, rich with growing economies and potential friends nervous about Chinese expansion.

“If we put all of our energy into the Middle East, or just into reacting, we won't get things done,” said Susan Rice, one of Obama’s closest advisors and, in his second term, his national security advisor.

But the focus on Asia faded as other threats emerged — including Al Shabaab in Somalia, Al Qaeda in the Arabian Peninsula in Yemen, Ansar al Sharia in Libya, Al Qaeda in the Islamic Maghreb in Mali, the Taliban in Pakistan and, ultimately, Islamic State around the world.

Obama sent Navy SEALs and Army Delta Force commandos to raid militant hide-outs in Libya, Somalia and elsewhere. He personally approved the CIA-led SEAL raid that killed Osama bin Laden in Pakistan in May 2011.

But he mostly relied on Predators and other increasingly sophisticated drone aircraft — first to conduct aerial surveillance and then to launch deadly Hellfire missiles.

An unmanned U.S. Predator drone flies over Kandahar Airfield in southern Afghanistan. (Kirsty Wigglesworth / AP)

Drones kept U.S. soldiers out of harm’s way and they were, arguably, more humane than other weapons because they could help find and kill specific individuals and limit civilian casualties.

At least in public, Obama wrestled with his growing reliance on drones and his use of them to carry out targeted killings.

He even ordered the killing of a U.S. citizen — Anwar Awlaki, a charismatic cleric born in New Mexico who worked for Al Qaeda in Yemen. Obama authorized the drone strike that targeted and killed him in September 2011.

U.S. drones also killed at least six other Americans in attacks aimed at militants. That suggests the weapons were not as precise, or the intelligence as reliable, as the administration has claimed.

In a speech at National Defense University in May 2013, Obama promised to provide more transparency about targeted killings.

It took three years, but in July the White House said up to 164 civilians had been killed in 473 airstrikes during Obama’s tenure, and that most involved drones. The tally did not include the wars in Iraq, Syria or Afghanistan.

Independent groups put the death toll much higher, saying hundreds of civilians were killed outside the war zones, and many hundreds more in them.

The war in Syria proved the greatest challenge for Obama, and much of his legacy may well depend on how history views his response.

In August 2012, Obama publicly warned that President Bashar Assad would cross a “red line” if his forces used chemical weapons against rebels seeking his ouster.

A year later, when poison gas attacks killed hundreds in rebel-held areas of Damascus, Obama faced a decision: Make good on his implied threat and launch cruise missiles and bombers against Syria’s government and military? Or back down to keep America out of a civil war?

Obama initially appeared on the verge of ordering a massive attack. The Pentagon moved warships into place, readied missiles and bombers, dusted off targeting plans and waited for the go signal.

Then he hit the brakes.

On Aug. 30, Obama took a walk on the South Lawn of the White House with his chief of staff, Denis McDonough. Later they called senior aides together and Obama told them he wouldn’t bow to pressure from critics in Congress and elsewhere to get America into another Mideast war.

“These guys, because of the politics of the moment, are pushing me to take action that is going to have real consequences for Americans,’” Obama said, one senior staffer recalled. “He said, ‘I’m not going to do that.’”

The news stunned the group. Secretary of State John F. Kerry had been so confident Obama was about to launch the missiles that he’d given a speech that day at the State Department, implying an attack on Assad was on the way.

The next day, Obama appeared in the Rose Garden to say he was prepared to order airstrikes but the American people deserved a vote. He asked Congress to pass a joint resolution authorizing use of force in Syria.

Obama speaks about the situation in Syria from the White House Rose Garden on Aug. 31, 2013.

When lawmakers made clear they would reject the resolution, no vote was held — and no missiles were launched.

Instead, prodded by a United Nations Security Council resolution, Syria handed over 1,300 tons of chemicals and other material used to make sarin nerve gas and mustard blister agent, and the production equipment, for destruction at sea. Assad’s most toxic weapons were eliminated by August 2014.

James Stavridis, a retired U.S. Navy admiral who served as NATO supreme commander until 2013 and is now dean of the Fletcher School of Law and Diplomacy at Tufts University, said Obama’s lack of action in Syria would not be forgotten.

He “will be judged harshly for … failing to enforce the so-called red line in Syria against Assad's use of chemical weapons,” he said. “And for not taking out Assad's air force before the Russian involvement, which made it vastly more difficult to do.”

Obama thinks history will side with him for showing restraint. He kept America out of an unnecessary war with no clear military solution. And his cautious approach worked: Syria surrendered its lethal chemical arsenal .

“This wasn’t simply about being ambivalent about [sending] combat troops,” Rhodes said. “It was about making an analysis that it wasn’t going to solve the problem.”

Contact the reporters. Follow @cparsons and @wjhenn on Twitter.