The train, named "Yixinou", left Yiwu, 300km south of Shanghai, and will cross Kazakhstan, Russia, Belarus, Poland, Germany and France before arriving in Spain in December.
The total distance covered by the new rail route is greater than that of the world's longest train service, the 9,259km Moscow-Vladivostok Rossinya 002, and five times as long as the route of the famous Orient Express.
But unlike on the Russian train, goods on the Yiwu-Madrid route will have to be shifted onto different wagons at three points due to incompatible track gauges in different countries, including between France and Spain.
Although the high-speed rail link between Barcelona and France was designed to avoid this, goods destined for anywhere in Spain except Barcelona must be switched to trains designed for Spanish tracks.
Yiwu is the biggest wholesale hub in the world and Chinese authorities wanted to connect it by rail to Europe, one of the city's biggest markets.
A spokesperson for China's state press agency said that the new line "would reduce dependence on sea and air cargo transport".
The new freight route has been made possible thanks to IRS InterRail Services GmbH, which is based in Berlin, and with the cooperation of Chinese Railways and DB Intermodal.