Josep Borrell, a former president of the European Parliament, revealed the conversation this week, explaining how Mr Trump shrugged off his scepticism about building a wall through 3000 miles of desert.
According to Borrell, Trump brushed off concerns about the plan's feasibility, claiming that "the Sahara border can't be bigger than our border with Mexico".
The United States' border with Mexico spans almost 2,000 miles, while the 3.5 million-square-mile Sahara is about 3,000 miles long and stretches across almost a dozen North African countries.
Building a wall through the Sahara would be more complicated still, given that Spain would need the co-operation of foreign nations to build on their territory.
Since the start of 2018, more than 38,000 migrants have arrived in Spain, mostly by sea.
Immigration is a hot topic in Spain, as it is in much of Europe.
It was at a recent lunch in Madrid that Borrell made the U.S. President's idea public.
Prototypes of Donald Trump's proposed wall are being built near San Diego, California.
Spain has now overtaken Italy and Greece as the most popular destination for migrants.
They are situated a considerable distance north of the Morocco/Algeria border - across which the Sahara lies.
Spanish diplomats, however, pointed out that the Sahara Desert stretched for 3,000 miles. Diplomatic sources say that it was probably in late June, when the minister visited the United States in a trip coinciding with that of the Spanish King and Queen.
The enclaves have become magnets for African migrants seeking a better life in Europe.