Although exports by Spanish companies reached an annual record, internal consumption caused imports to grow even more strongly, the economy ministry said.
The shortfall of exports to imports in the eurozone's fourth biggest economy grew by 53.4 percent to €24.47 billion ($28 billion), figures from the ministry showed.
That was bigger than the figure for 2013, the year gradual recovery started, but it was still Spain's second-smallest trade deficit since 1998, the ministry said.
This year's deficit figure "comes in a context of rising imports linked to the economic recovery", the ministry said in a statement.
The recovery drove up imports by 5.7 percent to nearly €265 billion, with a particular increase in imports of industrial equipment.
On the consumer side, sales of cars and electric appliances in Spain also strengthened, it said. Automobile imports to Spain grew by nearly a fifth in 2014.
Aided by a weakening euro making products from eurozone countries cheaper for purchasers overseas, Spain's exports grew by 2.5 percent to €240 billion.
Overall that level was "a record for annual exports", the ministry said in a statement.
Most of Spain's foreign trade was done with other countries in the European Union. Its biggest trade partners are Germany, Italy, Portugal and France.
After six years of stop-start recession that destroyed millions of jobs,
Spain's economy grew by 1.4 percent in 2014, according to the government's latest estimates.
The government is trumpeting the recovery ahead of a general election due around November. But the unemployment rate remains extremely high at nearly 24 percent.