As President Obama travels to South Africa for Nelson Mandela's memorial service on Tuesday, it might seem as though Mandela was an eternal object of admiration for U.S. presidents and the American public. But that wasn't the case by a long shot.
During Mandela's 27 years behind bars, successive U.S. administrations worked with, or at least tolerated, South Africa's white leaders. Only in his final years of incarceration did he and the anti-apartheid movement become a cause that gained traction in the United States.
In 1981, when apartheid was still in full force, President Ronald Reagan told CBS that he supported the South African government because it was "a country that has stood by us in every war we've ever fought; a country that, strategically, is essential to the free world in its production of minerals."
Mandela's prison years coincided with the final quarter-century of the Cold War, and that global battle largely defined the relationship between the U.S. and South Africa's white rulers.
U.S. presidents and South African apartheid leaders saw themselves as bulwarks against communism, and this trumped the issue of systematic racial discrimination in South Africa.
"For decades, American presidents backed apartheid in the name of anti-communism," noted commentator Peter Beinart. "In South Africa, it was the Soviet bloc — the same communist governments that were brutally repressing their own people — that helped the ANC fight apartheid."
In addition, Mandela's politics were complicated.
His African National Congress has been closely aligned for decades with the South African Communist Party. Members of both organizations studied and received military training in the Soviet Union. And while Mandela and other ANC leaders called for a multiracial democracy, many members of his group viewed communist countries as more sympathetic to their cause than Western nations.
British historian Stephen Ellis published a 2011 paper citing documents from the South African Communist Party that state Mandela was one of the group's leaders.
Whatever Mandela's role may have been, his open alliance with the Communist Party was often cited by South Africa's government and some conservatives in the United States as reason to be suspicious of him and the ANC's intentions.
For years, the U.S. labeled the ANC a terrorist group because it carried out attacks against civilian targets in South Africa. And it was Mandela himself who established the ANC's armed wing in the early 1960s before he was imprisoned.
The U.S.-South African relationship began to change after black South Africans launched a major uprising in 1984 pushing the anti-apartheid struggle onto American TV screens and newspaper front pages.
Soon after, U.S. politicians, many of them Democrats in Congress, began marching in front of the South African Embassy in Washington, D.C., getting themselves arrested by the dozens.
Congress then passed economic sanctions against South Africa in 1986. Reagan vetoed the bill, but Congress overrode him. The sanctions were limited and were never going to bring down the South African government. But the law marked the moment in the U.S. that South Africa became a moral and civil rights question, as opposed to a Cold War issue.
When South African President F.W. de Klerk freed Mandela in February 1990, fewer than three months after the Berlin Wall came down, he cited the collapse of communism as a key factor in his decision. De Klerk said South Africa no longer feared a communist takeover sponsored by the Soviet Union and that he was now willing to embark on negotiations with Mandela.
As a free man, Mandela was feted by U.S. presidents. Obama had a particular affinity, citing Mandela as a hero and noting that his own political activity began with involvement in anti-apartheid activism in the U.S. in the 1980s.
However, Mandela was at odds with U.S. foreign policy on multiple occasions.
He remained loyal to those who provided moral and financial support to his group during the years when the ANC had few friends in the West. This led Mandela to meet and praise leaders such as Cuba's Fidel Castro and Libya's Moammar Gadhafi.
The year after he was freed, Mandela called Castro "a source of inspiration to all freedom-loving people."
Mandela also spoke out against the U.S. invasion of Iraq in 2003 and took issue with the U.S. campaign against Iran's nuclear program.
But on Tuesday, Obama is scheduled to address a packed stadium in Soweto, and the only topic that matters will be the way Mandela remade his country and served as an inspiration to the world.