MADRID -- The Spanish Supreme Court ruled Tuesday that the country's caretaker government can exhume Francisco Franco's remains from a gigantic mausoleum the military dictator had built outside Madrid, a decision that could settle a decades-old controversy.

Six judges unanimously rejected an appeal brought by Franco's relatives over the Socialist government's plan to move the remains to a cemetery on the capital's outskirts. Franco ruled Spain from 1939 until his death in 1975.

But there is still at least one more legal hurdle to be cleared before exhumation can begin. The government needs a Madrid lower court judge to lift a suspension order he placed last February on the permit to begin excavation at the mausoleum, following a petition on behalf of the Franco family. It is not clear when or if the judge will annul that order.

Left-wing parties and families of people killed by Franco's forces during the Spanish Civil War want Franco's remains removed from the Valley of the Fallen mausoleum, a major tourist attraction.

Other Spaniards have argued the transfer would open old wounds from the bloody 1936-39 war between supporters of the Republican government and rebel military Nationalists led by Franco.

Some 34,000 people from both sides in the war are also buried at the Valley of the Fallen, most of them never identified.

Franco's family hoped to block the exhumation or at least have the remains reburied at central Madrid's Almudena Cathedral, an idea vehemently opposed by the government.

The ruling came as Spain's parliament was dissolved and an election set for Nov. 10; opposition parties have accused the Socialists of planning to use the exhumation for electoral purposes.

The ruling can't be appealed but lawyer Luis Felipe Utrera said the dictator's relatives intended to take "the legal battle to the end" by going to the country's constitutional Court and the European Court of Human Rights.

"The government is prohibiting a family from burying one of their own where they deem convenient," Utrera told Spanish public broadcaster TVE.

Such legal challenges would not immediately stop the Socialist executive's plans.

Prime Minister Pedro Sanchez, who is holding office in a caretaker role after leading a previous government, tweeted that the Supreme Court decision was a "great victory for Spanish democracy."

"The determination to make up for the suffering of the victims of Francoism has always guided the government's action," Sanchez wrote.

His deputy, Carmen Calvo, said the government intended to proceed with the exhumation "as soon as possible."

Bonifacio Sanchez, spokesman for Spain's Association of Historical Memory, which has long fought for the body's removal, said he welcomed the decision but opposed the government plan to take it to the El Pardo cemetery outside Madrid, where the Franco family has a crypt.

The cemetery is a publicly financed place and the remains should be given to the family for burial in a private location, he said.

He also dismissed the Franco's family's plans to appeal, saying that "the state cannot be dependent on what the family of one that has committed genocide says."

Experts recently estimated that the bodies of more than 100,000 Franco opponents who were killed in the civil war are buried in 2,500 mass graves across Spain. They say that most of the sites are unmarked, while another 740 mass graves and 9,000 bodies have been exhumed nationally since 2000.

The removal of Franco's remains is likely to be a momentous event. in Spain, which still bears social and political scars from the country's 1936-39 civil war started by Franco when he rose up against the democratic republican government.

The vast mausoleum complex can be seen for miles around and is the most conspicuous visible legacy of his rule. Thousands of Franco prisoners worked to build the Valley of the Fallen.

Lobbying for the exhumation began about 20 years ago, when supporters of the side that lost to Franco and relatives of Republic war dead started campaigning for government help to open the mass graves. Archaeological and identification work at grave sites also has been funded privately.

Spain approved a Historical Memory law in 2007 opening the way for Franco's remains to be exhumed and the other mass graves to be identified.

------

Associated Press reporter Aritz Parra in Madrid contributed

------

This story has been corrected to show the name of mausoleum in the 20th paragraph should be Valley of the Fallen, not Fallen of the Valley