President Obama speaks at a news conference after attending the Asia-Pacific Economic Cooperation Summit at the Lima Convention Center on Nov. 20 in Lima, Peru. (Brendan Smialowski/AFP/Getty Images)

One local radio host declared President Obama’s motorcade “impressive,” and Peruvians gathered along the streets to watch it roll by.

But for the most part, the crowds turning out to see the outgoing American president on his final foreign trip were smaller and quieter than on his previous outings. Those audiences were just one sign that Obama’s week-long valedictory journey had turned into less of a celebratory goodbye tour and more of a bittersweet farewell for a president whose worldview is now under siege.

At each stop — in Greece, Germany and Peru — Obama talked about the importance of respect for democratic norms and ensuring a smooth transition of power to President-elect Donald Trump, whom he mocked and dismissed for months. He made fond remarks about a few longtime allies, telling German Chancellor Angela Merkel that he wished he “could be there to lighten her load” as she carries on their shared vision of a more inclusive West.

The president voiced optimism about the “strong handoff” he’s giving Trump and about the future course of global events. But he also fretted about the rise of a “crude nationalism” that has gained currency worldwide, and the fact that social-media discourse makes no distinction between fact and fiction.

Throughout it all, Obama made appeals to Trump as he fended off questions about how his successor would rewrite U.S. policy on trade, immigration, the environment and other issues. At one point, he plaintively predicted that reality would force Trump to adjust his approach to problems he has promised voters he would easily solve.

Obama's foreign policy of restraint was both pragmatic and problematic.

“And I’ve said before, if these issues were easy — if ensuring prosperity, jobs, security, good foreign relations with other countries — if all that was simple, then it would have been done by every previous president,” he said at a news conference Sunday. “And I’m a pretty good presidential historian; I’ve looked at my 43 predecessors, and it seems like for all of them — even the best ones — that you end up confronting realities that you didn’t anticipate.”

Obama faced the same predicament as both of his immediate predecessors: He hoped to make one final mark on the world stage even as a very different president, from the other party, waited in the wings.

Bill Clinton journeyed to Ireland and Britain, in part to make the case for the Northern Ireland peace accord that his administration had brokered. But he ended up staying up most of the night while visiting then-Prime Minister Tony Blair and his wife, Cherie Blair, at Chequers, watching Vice President Al Gore concede the 2000 presidential election after the Supreme Court’s ruling on the outcome in Florida.

Although George W. Bush emerged the victor that December day, he experienced an even more fraught final trip eight years later, when he journeyed to Iraq and Afghanistan to visit U.S. troops and negotiate the withdrawal of forces from Iraq. Standing at a news conference beside then-Iraqi Prime Minister Nouri al-Maliki, Bush was nearly hit by a shoe thrown by a reporter, Muntadhar al-Zaidi — the worst expression of contempt in Iraq.

“This is a farewell kiss!” Zaidi yelled at first, unsuccessfully throwing a second shoe before Iraqi security officers tackled him.

For Obama, the crowds were friendlier than they were for Bush — but they were much smaller than when he started his political rise in 2008.

As he traversed Athens for a day and a half, the city’s residents were barely visible — largely because of security measures imposed by the Greek government. Some Greeks stood by the roadside for a glimpse of Obama’s motorcade, but few waved, and it was nearly impossible to spot the enthusiastic handmade signs that had invariably popped up along Obama’s route in world capitals as well as small American towns.

The president had been scheduled to deliver his “big speech” of the trip with the iconic Athens landscape as the backdrop, but weather concerns forced it indoors. As a result, Obama made his pitch for addressing global inequities inside a brand-new and well-appointed concert hall, whose very construction amid an ongoing economic crisis rankled ordinary Greeks.

The night Obama arrived, ­Katarina Sarficka, a Slovakian tourist, asked young people on the street whether they were gathering to see the American president — only to learn they were using the occasion to demonstrate their opposition to globalization. “They were protesting their own government,” she said.

Greek author and journalist Yannis Palaiologos noted that Greeks’ view of the United States has improved under Obama’s tenure; there were far worse riots when Clinton came in 1999. But “there is considerable fatigue and fatalism among the people regarding the prospects of the country — a sense accentuated by the victory of Donald Trump, which took a lot of the air, in terms of substance, out of Obama’s visit.”

Jeff Shesol, a Clinton speechwriter who traveled with him on his last trip, said there’s “a cognitive dissonance” that happens once someone has been selected to take the president’s place.

“You still have some say over the course of events, but the center of action is elsewhere, and the focus of action is elsewhere,” Shesol said. “In the run-up to election, there’s always a sense of being on marked time, but there is still only one president. When there’s a president-elect, it’s different. And when that person is vowing to undo much of what you’ve done, it is much, much worse.”

In many ways, it was the shock of Trump’s win that appeared to reverberate across every country Obama visited, despite the distance between them. In Lima, taxi driver Alfredo Baca said that Latin America has “demagogues, but this is the United States.”

Still, he said he understands that Americans’ frustration could translate into a shift in direction. “It’s the laws of physics: For every action, there is an equal and opposite reaction.”

Many world leaders appeared sorry to see Obama go. The normally unsentimental Merkel, who has made no secret of her concerns about Trump’s commitment to liberal social values, remarked during their joint news conference, “Now, taking leave from my partner and friend, well, yes, it is hard.”

Obama heaped appreciation on his closest allies and worked to cultivate younger leaders who could carry on some of the efforts he has pursued over the past eight years. Sitting next to Canadian Prime Minister Justin Trudeau in a conference room in Lima, with the Canadian and American flags draped behind them, the president spoke approvingly about his younger counterpart’s work on climate change and humanitarian causes such as refugee resettlement.

“So I have to say that there are few leaders around the world who I think combine vision and talent and values the way that Justin does,” he said. “And I am very much looking forward to his continued leadership in the years to come.”

And although Europeans appeared weary after struggling with unrelenting economic, security and social challenges for the past decade, Peru gave Obama some cause for optimism. His last public event of the trip was a town hall meeting with 1,000 young people, including 100 participants in the new Young Leaders of the Americas Initiative. The administration program, which has counterparts in Africa and Asia, aims to train the next generation of global activists through exchanges with the United States.

Pacing a stage in the middle of the gym at Lima’s Pontifical Catholic University, his jacket off, Obama spent an hour answering questions from students. He noted that half of the global population was younger than 30, and after meeting members of that age cohort from “around the world, it makes me very optimistic to know that you are going to be in charge.”

They cheered when he said that girls need to be told often that “they’re smart, and you got to tell them they’re ambitious, and you have to give them opportunity.” They laughed when he said he would “not be attempting the Marinera” because his wife is a better dancer. And they seemed to share his impatience when he told them that they should begin organizing now rather than waiting until they held political office.

“Don’t wait, saying to yourself, ‘Oh, someday, when I’m president of Peru, I’m going to help poor children,’ ” he said. “If you care about the environment, don’t wait.”

Shortly afterward, Obama wrapped up the town hall meeting, singer Marc Anthony’s “Vivir Mi Vida” blasted through the gym’s speakers, and Obama moved around shaking hands. Many in the audience held up smartphones and took one last round of images of an American president making his exit from the world stage.