If Africa is a country, then Fidel Castro is one of our national heroes. This may come as a surprise to many oblivious of Africa’s postcolonial history and Castro’s role in it – especially the fate of white regimes and former Portuguese colonies in southern Africa. In the west, Castro’s legacy is usually dismissed as an authoritarian, and Cuba as a one-party state with few freedoms. Despite the many achievements of Cuba under Castro (high quality public healthcare, as well as life expectancy, child immunisation and literacy systems parallel to those of first-world nations, and even surpassing the US), at various times the country became renowned for economic crisis, media repression, exiling and imprisoning dissidents, and discriminating against gays and people with AIDS.

Those things were a betrayal of the revolution, and it is important to acknowledge that. But history has absolved Castro when it comes to Cuba’s foreign policy, especially its Africa policy.

A great irony about the reaction to Castro is that many of the same people demanding acknowledgement of his wrongs have never acknowledged that their governments were on the wrong side of history, or sponsored dictatorships in many developing countries.

After fronting the Cuban revolution against a corrupt, American-sponsored dictatorship in 1959, Cuba under Fidel worked hard to develop its own distinct foreign policy independent from that of its more powerful neighbour, the United States, or its supposed ally, the Soviet Union. Africa became central to that foreign policy. For me, and people of my generation, Fidel Castro entered our consciousness as a hero of our liberation. He wasn’t just fighting for an abstract cause. He was fighting for us.

One of Castro’s central foreign policy goals was internationalism – the promotion of decolonisation and revolutionary politics abroad. This involved sending troops to fight in wars against colonial or proxy forces on the African continent, as well as supporting those movements with logistical and technical support. Cuba sent troops but it also sent tens of thousands of Cuban doctors, dentists, nurses, health-care technicians, academics, teachers and engineers to the continent and elsewhere. That a significant proportion of Cubans trace their ancestries to west and central Africa (owing to slavery) contributes to this politics.

Critics of Cuba have pointed to the paradox of Cuba’s African policy: while Cuba has a progressive foreign policy on race, at home Afro-Cubans have often been at odds with the Communist party’s failure to reflect the full range of Cuba’s racial diversity in its leadership structures or to fully address race politics.

Castro’s regime did achieve more for Afro-Cubans in 50 years than previous administrations had in the last 400 years. But as the Council on Hemispheric Affairs concludes, Castro’s policies “only addressed issues of unequal access without changing structural biases underlying society”. And it added, with the new wave of economic changes affecting the country, “race and racism are once again becoming important issues in Cuba”.

Cuba’s involvement in Africa started with its support of Algeria’s liberation struggle against France, then moved to the Congo, now the Democratic Republic of Congo (DRC). In 1964 Castro sent his personal emissary, Che Guevara, on a three-month visit to a number of African countries. The Cubans believed there was a revolutionary situation in central Africa, and they wanted to help, argues the historian Piero Gleijeses.

While Cuba record in the Horn of Africa was mixed under Castro (it followed the Soviet Union’s lead in militarily aiding Ethiopia’s dictatorship against a Somalian invasion and Eritrean independence fighters), successes did follow elsewhere, where it pursued a more independent foreign policy.

Even as Cuba’s intervention struggled in Congo, Amilcar Cabral, leading a guerrilla struggle against Portuguese colonialism in Guinea Bissau and Cape Verde, asked for Cuban assistance. Between 1966 and 1974 a small Cuban force proved pivotal in the Guineans’ victory over the Portuguese. Following the Carnation Revolution in Portugal in 1974, Guinea-Bissau finally won independence.

Cuba’s involvement in the freedom of South Africa from white minority rule was even more dramatic. Twice – in 1976 and again in 1988 – the Cubans defeated a US-supported proxy force of the South African apartheid army and Angolan “rebels”. These instances were the first times South Africa’s army was defeated, a humbling experience that the apartheid regime’s white generals still, in retirement, find hard to stomach.

As Gleijeses told Democracy Now! in December 2013, at the time of Mandela’s passing, black South Africans understood the significance of these defeats. The black South African newspaper the World wrote about the skirmishes: “Black Africa is riding the crest of a wave generated by the Cuban victory in Angola.”

Gleijeses remembered Mandela writing from Robben Island: “It was the first time that a country had come from another continent not to take something away, but to help Africans to achieve their freedom.”

In a 1998 speech, Fidel Castro told the South African parliament during his first visit to the country that by the end of the cold war at least 381,432 Cuban soldiers and officers had been on duty or “fought hand-in-hand with African soldiers and officers in this continent for national independence or against foreign aggression”. Many Cubans also lost their lives in these wars. In 1987, the Los Angeles Times reported that “10,000 Cuban troops have been killed in Angola since 1976 … proportionately much higher than American fatalities in Vietnam”.

Given this history, it was no surprise that one of Mandela’s first trips outside South Africa – after he was freed – was to Havana. There, in July 1991, Mandela referred to Castro as “a source of inspiration to all freedom-loving people”. At the end of his Cuban trip, Mandela responded to American criticism about his loyalty to Castro: “We are now being advised about Cuba by people who have supported the apartheid regime these last 40 years. No honourable man or woman could ever accept advice from people who never cared for us at the most difficult times.”

The cold war ended a long time ago, but Cuba continues its involvement on the African continent, including training Africans in Cuban universities. During the Ebola outbreak in three west African countries, even Cuba’s US critics had to acknowledge the Cuban contribution to alleviating the crisis. At one point during the Ebola crisis, Cuba – a country with only 11 million people – had supplied the largest contingent of foreign medical personnel by any single nation working alongside African medics.

Altogether fitting was President Raúl Castro’s address at Nelson Mandela’s funeral in 2013. In Johannesburg, Raúl reminded his audience: “We shall never forget Mandela’s moving homage to our common struggle when on the occasion of his visit to our country on 26 July, 1991, he said: ‘The Cuban people have a special place in the hearts of the peoples of Africa.’”

If Raúl Castro decided to give all the credit for that love to his older brother, Fidel, no one would blame him.