MADRID — The remains of Spanish dictator Francisco Franco were exhumed from his mausoleum on Thursday and reinterred in a cemetery on the outskirts of Madrid, delivering on a pledge made by acting Prime Minister Pedro Sánchez.

Franco, who died in 1975, was buried at the Valley of the Fallen, a huge monument he had built in the mountains north of the capital. His resting place had long been controversial, with campaigners saying it glorified the legacy of a brutal despot.

On Thursday, 22 relatives of Franco visited the Valley of the Fallen for the exhumation. In the basilica drilled into the mountain where the dictator was buried, a 1.5-ton granite slab covering the tomb was removed and Franco’s coffin was lifted out and transferred via hearse to a helicopter.

Some of those present shouted “Long live Spain! Long live Franco!” as the coffin emerged from the basilica.

Media access to the site was tight and a canopy was hung over the tomb to prevent drones from photographing the exhumation.

Franco's resting place had long been controversial, with campaigners saying it glorified the legacy of a brutal despot.

Justice Minister Dolores Delgado and Francis Franco, one of the dictator’s grandchildren, accompanied the remains on their journey to Mingorrubio cemetery, north of Madrid, where Franco’s widow is buried. His remains were then reburied and a Catholic Mass held.

“Having the dictator there in that mausoleum was an affront,” said Sánchez after the exhumation and reburial.

“In a few days, when the Valley [of the Fallen] opens its doors again, those who go there will find a different place.”

Sánchez pledged to exhume Franco on taking office in June 2018, arguing that the Valley of the Fallen, which Franco had built between 1940 and 1959 using imprisoned political opponents, was an inappropriate site for a dictator’s resting place.

A massive stone cross, 150 meters high, towers above the site, which offers sweeping views of the Guadarrama mountains and surrounding valleys. Franco’s tomb was located behind the altar at the far end of the basilica, next to that of another icon of the far right, José Antonio Primo de Rivera, who founded the Falange party.

Franco was one of the leaders of a military uprising against Spain’s elected Republican government which triggered the 1936-1939 civil war. He took control of the country after leading the right-wing Nationalists to victory in the conflict. Although he ensured Spain was neutral in World War II, Franco was responsible for tens of thousands of deaths as he waged reprisals against Republicans.

Activists say more than 100,000 victims of Franco still lie in unmarked graves, the second-highest number in the world after Cambodia, according to Amnesty International.

After his death in 1975, Spain made the transition to democracy and the issue of historical memory was mostly kept out of the political arena. A 2007 Historical Memory Law sought to remove symbols of Franco and his regime from public places, but the Valley of the Fallen remained untouched until now.

A group of far-right supporters of Franco gathered outside Mingorrubio cemetery as the exhumation was taking place, to demonstrate against the process.

“This is cowardice and it’s shameful,” said Roberto Sánchez, a Franco supporter who was at the cemetery. “It makes no sense at all. It’s an absurd attitude, even for communists.”

“Having the dictator there in that mausoleum was an affront." — acting Spanish Prime Minister Pedro Sánchez

The government was keen to deliver on the exhumation plan before the November 10 general election.

However, delays and legal challenges plagued the exhumation almost right up until the last moment. The Franco family objected to the idea and sought to block it before the supreme court.

The family said that if the exhumation was allowed to go ahead, the reburial should be in a crypt beneath Almudena cathedral in central Madrid, where Franco’s daughter is buried. That raised concerns that the cathedral would become a pilgrimage site for extremists.

However, the supreme court quashed the Franco family’s complaints last month, and approved the government’s choice of reburial site.

Another obstacle was the long-standing refusal to cooperate of Santiago Cantera, the prior of the Benedictine community that manages the basilica at the Valley of the Fallen. Cantera, who was an electoral candidate for the far-right Falange in the 1990s, eventually complied and blessed Franco’s coffin as it was lifted from the tomb.