The eurozone's fourth biggest economy posted a surplus of €634.9 million ($817 million) in March, compared to a deficit of €3.245 billion a year earlier, the Economy Ministry said.
Imports in March plunged by 15 percent from a year earlier to €19.653 billion while exports grew two percent to €20.288 billion.
But the surplus is not in fact a sign of health in the Spanish economy, said Jose Garcia Montalvo, professor of economics at Barcelona's Pompeu Fabra University.
"Since the domestic economy has come to an abrupt stop, imports also have come to an abrupt stop," he told AFP.
"It is easy to get a trade deficit like that but the good news would have been that that imports were not falling, or only falling a little, and that exports were climbing a lot."
Grappling with a deep recession, stubborn public deficit and banks ridden with bad loans, the Spanish government seized on the trade surplus as a sign of strength despite difficult European markets.
"Exports to our European Union partners fell by 8.1 percent, reflecting the weak economy in the region," the Economy Ministry said in a statement.
However, "Spain is continuing its marked process of reorientating its sales to other markets where the economic outlook is more favourable," such as the Middle East, Africa and United States, it said.
Exports to countries outside the European Union surged 20.8 percent from a year earlier in March, accounting for 41.47 percent of all exports, the ministry said.
For the first three months of the year combined, Spain recorded a trade deficit of 4.048 billion euros, trimming the shortfall by 62 percent from a year earlier.
Imports in the quarter dropped 6.9 percent to €60.632 billion while exports rose 3.9 percent to 56.584 billion euros, the ministry said.
"The increase in the pace of Spanish exports contrasts strongly with the results of the main European trade powers," the Economy Ministry said of the quarterly figures, pointing to declines in exports from Germany and France.
Prime Minister Mariano Rajoy's conservative government has launched an austerity programme to find 150 billion euros in savings between 2012 and 2014 even as the country battles a recession and a record unemployment rate of more than 27 percent.
But many analysts say the tight-fisted policies have deepened the recession. The government is forecasting a 1.3-percent decline in gross domestic product this year.