President Obama remembered a personal hero Tuesday -- a man whose example "woke me up to my responsibilities" -- before an adoring and soaked stadium audience on the outskirts of Johannesburg.

At a soccer stadium in Johannesburg, South Africa, President Obama memorialized former South African president, Nobel Peace Prize laureate and anti-apartheid activist Nelson Mandela. (Associated Press)

In his words memorializing late South African president Nelson Mandela, Obama delivered a celebration and a scolding, a eulogy mixing past and present that, in its acknowledgment of failure, its emphasis on persistence and its call for cooperation, reflected this challenging moment in Obama's presidency.

The parallels he drew were unmistakable, as was the lilting, sometimes angry delivery he used to invoke them.

"There are too many of us who happily embrace Madiba’s legacy of racial reconciliation but passionately resist even modest reforms that would challenge chronic poverty and growing inequality," Obama said, referring to Mandela's clan name, less than a week after delivering a broad warning about the consequences of rising economic inequality in the United States. "And there are too many of us, too many, who stand on the sidelines, comfortable in complacency or cynicism when our voices must be heard."

Nearly a year into his second term, Obama is in a political trough at home after a series of legislative defeats and self-inflicted setbacks. His approval ratings have dipped to near record lows for his administration, with partisanship stuck at stubborn heights. His campaign promise to help guide the nation past its historic divisions -- over race and party and class -- appears as elusive today as when he took office.

Mandela, imprisoned for decades for leading the opposition to South Africa's white minority rule, faced far longer odds personally and politically than Obama has. As a student at Occidental College awaking to the political life around him, Obama found inspiration in Mandela, imprisoned and uncompromising. He joined the student-led divestment movement, calling it recently his first political act.

The euphoric audience inside First National Bank Stadium in Soweto, a former black township, provided a venue for Obama to regain some of that inspiration at a time when his administration appears largely out of new ideas for dealing with political opposition at home.

Just as Mandela's life has come to stand for tolerance and forgiveness, the theme of the occasion was reconciliation, political and personal, captured in microcosm by Obama's handshake with Cuban President Raul Castro, who also was invited to deliver a eulogy. Obama then sought out Frederik W. de Klerk, the last white president of South Africa, who shared the 1993 Nobel Peace Prize with Mandela.

Obama, cheered warmly by the large crowd, cast himself as a beneficiary of Mandela's movement for racial equality, even though it took place an ocean away from the continent where he began his political life. And in highlighting Mandela's qualities, Obama emphasized ones that he has said mark his own priorities, as a person and politician.

"He was practical," a pragmatic president told the audience.

"On core principles, he was unyielding," Obama said, echoing the explanations he has given supporters in the past for the sometimes-unpopular deals he has made with congressional Republicans. He added that Mandela "was not afraid to compromise for the sake of a larger goal."

"He changed laws but also hearts," the president continued, capturing what has been his own strategy for how to prepare the country, through a mix of legislation and rhetorical persuasion, to accept gay Americans in all aspects of public life.

But it was Mandela's imperfections that Obama appeared to find most relevant and resonant, and which seemed also to bring out some of the loudest roars from the crowd that knew Mandela best.

"It is tempting then to remember Nelson Mandela as an icon, smiling and serene, detached from the tawdry affairs of lesser men," Obama said. "But Madiba himself strongly resisted such a lifeless portrait." The ovation that followed was perhaps the loudest of Obama's 19-minute speech.

As the implementation of his signature health-care law has faltered badly in recent months, Obama has had occasion to highlight his shortcomings with what, for him, must seem to be alarming frequency. He has told his country that he "never promised to be a perfect president," and in Mandela's flaws, Obama found a way to explain his own.

"He insisted on sharing with us his doubts and fears, his miscalculations along with his victories," Obama said. "It was precisely because he could admit to imperfection -- because he could be so full of good humor, even mischief, despite the heavy burdens he carried -- that we loved him so. He was not a bust made of marble. He was a man of flesh and blood, a son and husband, a father and a friend."

Obama's trips abroad often serve as a reminder that, beyond his nation's borders, his story still inspires.

Huddled beneath umbrellas, the crowd erupted in applause when Obama --  his nation's first black president, on hand to celebrate the life of South Africa's first black president -- appeared on the jumbo screens around the stadium with first lady Michelle Obama beside to him. In contrast, there were boos and catcalls when South Africa's president, Jacob Zuma, was shown.

But domestic politics await the president, and his advisers have made clear that persistence, a quality Obama celebrated Tuesday in his late hero, remains the central element of the administration's strategy for the year ahead.

On immigration, criminal justice reform, economic initiatives, Obama, lacking a new strategy for dealing with his Republican critics, will just keep trying, inside and outside the Beltway, to make progress.

"Nelson Mandela reminds us that it always seems impossible until it is done," Obama said. "South Africa shows us that is true. South Africa shows us we can change."

 Read the transcript of Obama's speech honoring Nelson Mandela

 South Africans, world leaders bid farewell to Mandela

 In life, Mandela often irritated the U.S.