Rolling back his predecessor’s accomplishments is an obsession of President Trump’s. Nowhere is that clearer than in his handling of Cuba. Trump is reigniting the hostility between the two countries, limiting U.S. tourism to Cuba, cutting back on U.S. remittances to family members in Cuba, reducing embassy personnel in Havana and, last month, kicking out two of Cuba’s diplomats to the United Nations.

But if Trump’s goal is hurting the Cuban government, his actions are deeply counterproductive. They’ve damaged Cuba’s nascent private sector and overall economy and served as a boon to the Cuban government by restoring a hostility that has long been politically useful for Cuban leaders.

The true threat to the Cuban government was Trump’s predecessor, Barack Obama. Unlike Trump, he rejected hard-line, anti-Cuban policies and instead tried to break down the walls between the two nations, declaring on a historic visit to the island nation that “Cuba doesn’t have to be defined by being against the United States” and embracing commonalities between them.

The proof that Obama’s visit was threatening to the Cuban government came from Cuban Foreign Affairs Minister Bruno Rodríguez Parrilla, who dubbed Obama’s remarks “a deep attack on our ideas, our history, our culture and our symbols.”

How could conciliation and the first presidential visit to Cuba since 1928 be viewed as an attack?

Because Obama pointed out a dark commonality in the two nation’s histories: the role of white supremacy in building their economies. This was problematic for the Cuban government, not because it was untrue but because Cuba’s government long built support for Cuban nationalism (and by extension communism) by juxtaposing itself with the United States’ long history of racism. By reminding average Cubans that the nations had more in common — and that Cuba had a way to go to reach its stated egalitarian ideals — Obama threatened to undermine a crucial pillar of Cuban nationalism.

Nationalist ideologies invariably feed on narratives of uniqueness. Since the 19th century, Cuban nationalists have used race as a defining feature of what distinguishes the island from the United States, the land of segregation, racial violence and Jim Crow. As a veteran from the War of Independence (1895-1898), Lt. Col. Lino D’Ou stated in 1930, “For us black Cubans, the neighbor to the north … is the race of lynching!” American officials, scholars, investors and journalists, who often expressed contempt for Cuba in racist terms, helped solidify Cubans’ association between racism and the United States. As the Cleveland Press put it in 1911, “Cuba is politically impossible, socially impossible, economically impossible, because morally rotten … The fault is racial. Cuba … yields a hard, indocile mixed blood that riots in depravity.”

The Cuban revolution of 1959 transformed the contrast between Cuban and American domestic racial orders into an unbridgeable breach. In fact, authorities proclaimed that the eradication of racism and discrimination in the island was made possible only through the elimination of U.S. economic, social, cultural and political influences in Cuba. As Fidel Castro noted in a December 1959 speech, the United States had no moral standing to oppose a revolution that was “solving social conflicts … like the problem of racial discrimination.”

The very presence of Obama and his family in Havana demolished some of the most sacred pillars of Cuban nationalism. Here was an accessible, charismatic American president who was also African American. As he spoke of the advances black Americans have made since the civil rights battles of the 1950s and 1960s, Obama also insinuated that Afro-Cubans’ struggles for equality had not concluded yet. Then, by referencing the need to “help lift up” black Cubans, he directly challenged the official narratives of racelessness that had long infused Cuban nationalism.

Obama highlighted a shared historical foundation of slavery and colonialism that has shaped both Cuban and American history. He was of course correct: The modern United States and Cuba were built on the backs of enslaved Africans. Cuba led the way. In fact, by the time the first Africans arrived in a British colony 400 years ago, enslaved Africans had been toiling in Cuba for a century. Slaveholders in both countries created social orders that placed Africans at the bottom of society, tied whiteness to citizenship and equated blackness with enslavement. These racist orders, enshrined in law over centuries, turned blackness into a formidable barrier to mobility and prosperity, in Cuba as well as in the United States.

By the mid-19th century, when narratives of Cuban nationalism began to emerge, the process of embedding race into law had advanced further in the U.S. South than in Cuba. In other words, Cuban nationalism does contain a few kernels of truth.

But at the same time, mid-19th century Cuba was as brutal a slave plantation society as any of the states in the U.S. South. As in the United States, the end of slavery in Cuba was achieved by bloody military conflict. Emancipation was driven by the actions of black insurgents and of enslaved individuals, who made use of every available recourse to escape bondage. Indeed, Cuban white patriots and intellectuals had to invent myths of racial harmony and fraternity precisely because black agency could not be ignored or fully contained. As they constructed a supposedly inclusive and raceless nation, the crass racism of the post-Reconstruction United States came in handy.

By placing both countries on shared historical trajectories, Obama’s visit shook up not only American-Cuban relations but also the historical narratives that had sustained Cuban racial exceptionalism for more than a century. Moreover, by noting improvements made by American society in the area of race and inequalities that still exist in Cuba, he challenged the very basis of Cuban nationalism. This is why the foreign affairs minister characterized his remarks as a “deep attack.” Cuban authorities did not know how to handle a friendly, black American president.

The election of Donald Trump is, in that sense, a boon to Cuban nationalism; he is the perfect caricature of a grotesque, arrogant, ignorant imperialism that is reassuring to Cuban authorities and provides a useful foil. As Trump transforms the White House into the Whites’ House, his racist tweets and statements are the stuff that those wishing to restore a racially based contrast between the United States and Cuba could have only dreamed of.

Obama understood well that a new relationship with Cuba would have to build on commonalities, even if those commonalities are as execrable as racism and enslavement. Cuban authorities could not stomach the notion that these shared pasts shape lives, opportunities and practices, in both Cuba and the United States, in sometimes similar ways. President Trump has come to their rescue, giving them, again, the gift of American racism.