The train departed Yiwu in eastern China, a major wholesale centre for small consumer goods, on November 18 and passed through Kazakhstan, Russia, Belarus, Poland, Germany, and France during its 21-day trip.
The newly operational route is the longest railway route in the world, longer still than Russia's famous Transsiberian railway linking Moscow to Vladivostok near Russia's border with China.
The journey time was over ten days shorter than if the goods transported by the train had been shipped by sea, Spain's public works ministry said.
Speaking a ceremony in Madrid, Li Qiang, the governor of China's Zhejiang province where Yiwu is located, said the route was important to "implement the strategy of developing a new 'silk road'".
More From This Section
China has a regular direct freight train service to Germany, Europe's largest economy.
One route links the Chinese megacity of Chongqing to Duisburg, a steel-making town and one of Germany's most-important transportation and commercial hubs.
The other route links Beijing, the Chinese capital, to Hamburg, Germany's second-largest city.
The Spanish capital already is "a European and international distribution hub" with good links to both Africa and Latin America, she said.
Euro Cargo Rail, a subsidiary of German freight operator DB Shenker Rail, is studying the possibility of starting a regular service between China and Spain during the first half of next year with two monthly trips.
Roughly 80 percent of global trade is shipped by boat as freight train service faces several technical and bureaucratic hurdles which vary according to country.