Exports jumped 18.6 percent from a year earlier to €20.398 billion while imports rose 7.2 percent to €22.04 billion.
A trade surplus is a factor of growth in an economy, whereas a deficit tends to sap growth.
"Particularly noteworthy are the increases in exports to emerging economies with the highest growth potential," the ministry said in a statement.
The biggest increase in exports was to markets outside of the European Union. Exports soared by 32.1 percent to China, 85 percent to Brazil and 151.9 percent to South Africa.
By comparison exports to the rest of the European Union, where Spain's main trading partners are also battling recession, were up by 13.2 percent.
Exports of automobiles and motorcycles jumped by 26.8 percent, textiles by 32.3 percent and transportation equipment by 61.8 percent.
Exports have been a rare bright spot for the Spanish economy which is struggling to recover from a property crash in 2008 that has pushed the jobless rate up to a record 27 percent, saddled banks with a pile of bad loans and caused government debt to soar.
Prime Minister Mariano Rajoy's conservative government has made reforms, such as changes to labour market rules, that have reduced labour costs and help make Spanish goods more competitive.
But the International Monetary Fund, in an annual review of the Spanish economy published on Wednesday, warned that labour reform "needs to go further to generate jobs".
"The external sector will likely continue to be the bright spot, but probably not enough to generate sufficiently strong growth given weak domestic demand," it added.
Spain posted a trade surplus of €634.9 million in March, its first monthly trade surplus since 1971 as imports slumped because of a collapse in demand due to the economic downturn.