“Closing ports is not a solution, and neither is building a wall along the Sahara like President Trump suggested to me recently,” Josep Borrell told a lunchtime gathering this week, according to a video released by Spanish media.
“'Just build a wall that borders the Sahara',” he quoted Trump as telling him.
“'But do you know how big the Sahara is?',” the minister responded.
He did not give any further details.
The reported comments come as EU leaders are locked in talks in Salzburg over how to deal with the number of migrants arriving in Europe.
Spain is at the frontline of this issue, having overtaken Italy to become the number one point of entry for migrants coming to Europe by sea or by land from Africa.
Many of these cross the Sahara to Morocco and on to Spain across the Mediterranean or over two high fences into the Spanish overseas territories of Ceuta and Melilla in northern Morocco.
Trump's proposed wall along the US-Mexico border, which spans 3,200 kilometres (2,000 miles), could cost up to $20 billion (17 billion euros) according to some estimates.
The Sahara desert, meanwhile, spans all of northern Africa from the Red Sea in the east to the Atlantic Ocean in the west, or close to 5,000 kilometres.