Secretary of State Hillary Rodham Clinton speaks at the University of the Western Cape about U.S.-South Africa partnership on Aug. 8, 2012, in Cape Town, South Africa. (Jacquelyn Martin/AP)

In a rare and unusually personal reflection on forgiveness and redemption, Secretary of State Hillary Rodham Clinton urged South African students too young to remember apartheid not to lose sight of the example their country holds for the world and for themselves.

Clinton, who is nearing the end of her term as the United States’ top diplomat, wrapped a message about statesmanship into unscripted references here Wednesday to her own unique transformation from a pilloried first lady and unsuccessful presidential candidate.

“I’ve been in and around politics a long time,” said Clinton, who is on an eight-nation African trip. “It’s easy to lose sight of the common humanity of those who oppose you. You get to feeling that your way is the right way, and that your agenda is the only one” worth pursuing.

It becomes all too easy, she said with a smile, to “dehumanize” anyone who disagrees with you.

Speaking to students and staff at the University of the Western Cape midway through her 11-day trip, Clinton challenged the audience to live up to South Africa’s position as a top power in the region and to the legacy of Nelson Mandela, a political prisoner-turned-president.

To make good on Mandela’s example, she said, South Africa must take on greater responsibility and shed some of its suspicion of Western ideas.

Distrust of the United States is strong here, as shown by a student protest outside the lecture hall. From behind police barricades, the demonstrators shouted and held up signs reading, “End Israeli and US Murder,” and “U.S. Stop Killing People In Middle East.”

Inside, however, Clinton appeared to charm an audience, which included 18- and 19-year-olds who weren’t born when Mandela walked out of Robben Island prison in 1990, and who were infants or toddlers when he became president of a democratic South Africa in 1994.

Clinton attended Mandela’s inauguration when she was first lady. She came amid a blur of scandals and investigations, including Whitewater, the Paula Jones sexual harassment lawsuit, the failed “Black Hawk Down” raid in Somalia and opposition to a national health-care proposal crafted by a task force she led.

The Clintons’ friend and deputy White House counsel Vincent W. Foster Jr. had committed suicide the year before, after writing bitterly about a culture of political bloodlust in Washington.

“When I came to that inauguration, in 1994, it was a time of great political conflict in my own country. My husband was president. People were saying terrible things about us both,” Clinton said.

The attacks were personal and political, and they made her angry, Clinton said. “I was beginning to think, ‘Who do they think they are?’ ” she said to laughter.

Mandela’s gracious invitation to three of his former white jailers to join the dignitaries at his inaugural lunch was a lesson in overcoming resentment and injustice, she said.

Clinton flew to a small village Monday to visit the ailing, homebound Mandela, 94, who remains a national icon in South Africa. “You are called to build on that legacy to ensure that your country fulfills its own promise and takes its place as a leader among nations,” she said.

Clinton alluded to tension between the United States and South Africa over such issues as intervention in Libya and U.N. sanctions against Syria, on which South Africa abstained rather than appearing to side with Western nations. South Africa’s foreign minister, standing with Clinton at a news conference Tuesday, said that the country’s position, “yesterday, today and tomorrow,” is that it will not interfere in another nation’s internal affairs.

“You are a democratic power with the opportunity to influence Africa and the world,” Clinton said, urging South Africa to lower trade barriers and stimulate the economies of its neighbors while expanding its international reach.

South Africa can be influential in resolving the standoff with Iran over its nuclear program, Clinton said. The United States and much of the world suspect the program is aimed at building a bomb. Iran denies that it is doing so.

“As the first country to voluntarily give up nuclear weapons, South Africa speaks with rare authority,” Clinton said. “You can most convincingly make the case that giving up nuclear weapons is a sign of strength, not weakness.”