Algeria has recalled its ambassador to Spain after Madrid changed a 42-year-old policy towards its former colony Western Sahara.
Algeria condemned Spain's "abrupt U-turn", saying on Saturday that Spain had previously demonstrated neutrality in the long-running conflict for the land.
Madrid has now backed Morocco's proposal to give it limited regional autonomy.
On Friday it called the proposal, which dates back to 2007, "the most serious, realistic and credible" initiative for resolving a decades-long dispute over the vast Saharan territory.
Morocco annexed Western Sahara in 1975 and in response Algeria has kept its border with Morocco closed for decades.
And, although Spain receives about 40 percent of its gas from Algeria, its foreign minister hinted on Friday that working with Morocco to tackle a separate issue — migration from sub-Saharan Africa — was more important.
"We want to strengthen cooperation in the management of migration flows in the Mediterranean and the Atlantic," José Manuel Albares said on Friday.
When the leader of the Western Saharan Polisario Front, Brahim Ghali, received treatment, covertly, for Covid in a hospital in northern Spain Morocco retaliated by allowing thousands of sub-Saharan African migrants to enter Ceuta, the Spanish enclave inside Morocco from its own border.
Algeria is pro-independence and has long hosted the leaders of the Polisario Front and wants a referendum on independence to be held, as does the United Nations.
Polisario returned to fighting Morocco in 2020. Before that a ceasefire mainly held that was brokered in 1991 by the UN.
Meanwhile around 180,000 ethnic Sahrawis have remained in refugee camps in southern Algeria for decades.
In 2020, US President Donald Trump recognised Moroccan sovereignty over Western Sahara after Morocco mended ties with Israel.
That further angered Algeria which then broke off diplomatic relations with Morocco.
US President Joe Biden has not reversed Trump's move.