Donald Trump was widely ridiculed earlier this week for suggesting that Spain emulate his $25bn dream for the US-Mexico border and “build a wall” across the Sahara desert.

According to Spain’s foreign minister, Josep Borell, the US president told him: “The Sahara border can’t be bigger than our border with Mexico.”

But Trump – and some of his critics – seems unaware that there is already a wall cordoning a corner of the Sahara. At 1,700 miles (2,700km) the Morocco Western Sahara wall, known as the Berm, is about 250 miles shorter than the US-Mexican border.

It is made of sand, patrolled by more than 100,000 Moroccan soldiers, and was designed to keep independence-seeking Sahrawis in the eastern part of the desert – and and away from the region’s natural resources.

Morocco has occupied its southern neighbour Western Sahara since 1975, when Spain, the colonial power, withdrew, and the north African country fought a 15-year war with the Polisario Front, the independence movement.

“When Trump is saying you should construct a wall in the Sahara – look at the effect of the wall in Western Sahara,” said Manuel Devers, the Polisario Front’s legal representative, noting that the minefield running alongside the Berm includes some of the densest landmine contamination in the world.

“Morocco decided to invade the rest of Western Sahara because of its natural resources, phosphates and fishing. Western Sahara has the most important fishing resources in all of Africa,” said Devers.

A landmine warning sign in Western Sahara. The desert wall is thought to be the world’s longest continuous minefield. Photograph: Feargus Cooney/Getty Images/Lonely Planet Image

“North Africa does not need a wall, it needs the end of the occupation of Western Sahara. You don’t need a wall, you need economic prosperity.”

European nations are trying to find ways to keep the number of migrants reaching its borders; many of them come from sub-Saharan Africa and take the “back way”, through the desert.

Last year, Italy struck a deal with militias on the Libya-Niger border to stop human trafficking.

“Militias are proactive and motivated by financial gain, whereas walling is not effective. Walls aren’t deterrents,” said Philippe Frowd, a security, migration and Sahel specialist at the University of Ottawa. “Trump is accidentally raising important questions.”

A wall such as the one the US president proposed would have to cross at least five countries and many important trade routes, said Frowd, who said Trump’s comments disregard the deep links between north and west Africa.

“The EU has something better than a wall – it has the Mediterranean sea and the partnership of governments like Niger’s. The numbers are down, it seems to be working,” Frowd said.

• This article was amended on 22 September 2018 to make clear that the Berm is shorter than the US-Mexico border, not more than twice its length as originally stated.