MADRID — The Spanish government on Thursday exhumed the remains of the former dictator Gen. Francisco Franco from the underground basilica that he built after winning his country’s civil war. The move had prompted criticism that, coming just two weeks before a national election, it would reopen old rifts in Spanish society.

Franco’s remains were flown by helicopter from the basilica where he was buried in 1975 to a cemetery near Madrid that contains a family crypt where his wife is buried and that is beside El Pardo palace, which Franco used during his rule.

The exhumation and reburial followed a yearlong judicial battle between the caretaker Socialist government of Prime Minister Pedro Sánchez and relatives of Franco who had sought to reverse the decision.