President George H. W. Bush shakes hands with South African national leader Nelson Mandela at the White House in Washington, June 25, 1990. Doug Mills / AP

From the White House to the halls of Congress, U.S. government officials have responded to the death of Nelson Mandela with a hail of testimonials to the late South African president’s leadership in the struggle for freedom and human rights.

Until five years ago, however, the U.S. officially considered Mandela a terrorist. During the Cold War, both the State and Defense departments dubbed Mandela’s political party, the African National Congress, a terrorist group, and Mandela’s name remained on the U.S. terrorism watch list till 2008.

Presidents Carter and Reagan and Congress had all instituted sanctions against the white minority South African government because of its policy of racial apartheid. But in 1986, Reagan condemned Mandela’s group, the ANC, which was leading the black struggle against the apartheid regime, saying it engaged in "calculated terror ... the mining of roads, the bombings of public places, designed to bring about further repression."

After the apartheid regime in South Africa declared the ANC a terrorist group, the Reagan administration followed suit.

In August of 1988, the State Department listed the ANC among "organizations that engage in terrorism.” It said the group ''disavows a strategy that deliberately targets civilians,” but noted that civilians had “been victims of incidents claimed by or attributed to the ANC.”

Five months later, in January 1989, the Defense Department included the ANC in an official publication, "Terrorist Group Profiles," with a foreword by President-elect George H.W. Bush. The ANC was listed among 52 of the "world's more notorious terrorist groups." (One of the others listed, Yasser Arafat's Fatah, is now the ruling party in the West Bank.)

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The publication referred to Mandela, who had once led the ANC’s military wing, as part of the "leadership," though by then he had spent more than a quarter century in prison. It also accepted the apartheid regime's claim that "ANC's operations -- which heretofore had sought to avoid civilian casualties -- abruptly changed. Attacks became more indiscriminate, resulting in both black and white civilian victims." Five months before the report was issued, the ANC had taken responsibility for some attacks that resulted in civilian deaths but had pledged to prevent a recurrence.

The report cited 13 attacks during the 1980s, many of which targeted government facilities, including a military command headquarters, an unfinished nuclear plant, a courthouse and SASOL, the government-owned coal-to-oil conversion facility. Of those incidents that resulted in deaths, the biggest was a car-bombing of the South African Air Force headquarters in Pretoria that killed 19 and wounded 200.

The report also claimed significant links between the ANC and Communist countries, noting that the ANC "receives support from the Soviet bloc, Cuba and a number of African nations in addition to contributions from the West." The DoD report added that the ANC received many of its weapons from the "Soviet Bloc" and listed among its "political objectives" the establishment of a "multiracial Socialist government in South Africa."

When the Defense Department’s report was issued, State quickly distanced itself from the harsh, Cold War rhetoric. Despite its own earlier dire characterization of the ANC, it called the group "a politically diverse organization, representing a range of views. It is the oldest black nationalist movement in South Africa."

But the Defense Department stood by its language, and Mandela and other ANC officials remained on the terror watch list even as President Bush welcomed Mandela, newly released from prison, to the White House in 1990. Because of what was described as a "bureaucratic snafu," their names were kept on the list until 2008, 14 years after Mandela had been elected president and nine years after he had left power. He was 90 at the time.

The terrorist designation finally proved too embarrassing for the U.S. government to ignore. In April 2008, during the last year of the George W. Bush administration, Secretary of State Condoleezza Rice told a Senate committee that her department had to issue waivers for ANC members to travel to the United States.

"This is a country with which we now have excellent relations, South Africa, but it's frankly a rather embarrassing matter that I still have to waive in my own counterpart, the foreign minister of South Africa, not to mention the great leader Nelson Mandela," Rice said.

Later that year, the terrorist designation was dropped after a bill, proposed by then-Senator now secretary of State John Kerry, passed both houses of Congress and was signed by President Bush.

Mandela was imprisoned in 1964 after being arrested and charged with sabotage, specifically a campaign against the country's power grid, and plotting to overthrow the government. No one was injured in the sabotage campaign. He was released in 1990, at age 71. He was elected president of South Africa in 1994, in the country’s first full and free elections, and served until 1999.

More from NBC News Investigations:

Follow NBC News Investigations on Twitter and Facebook