The longest rail link in the world and the first direct link between China and Spain is up and running after a train from Yiwu in coastal China completed its maiden journey of 8,111 miles to Madrid.

En route it passed through Kazakhstan, Russia, Belarus, Poland, Germany and France before arriving at the Abroñigal freight terminal in Madrid.

The railway has been dubbed the “21st-century Silk Road” by Li Qiang, the governor of Zhejiang province, where Yiwu is located. Its route is longer than the Trans-Siberian railway and the Orient Express.

The first train was met by the mayor of Madrid, Ana Botella, and Spain’s minister of public works, Ana Pastor. It consisted of 30 containers carrying 1,400 tonnes of cargo – mostly toys, stationery and other items for sale over Christmas across Europe.

According to China’s ambassador to Spain, Zhu Banzao, it will return laden with wine, jamón and olive oil in time for the Chinese new year in February.

Yiwu is the world’s largest wholesale hub for small consumer goods and plays host to a vast 4 sq km (1.5 sq mile) market where tens of thousands of traders work daily. The journey was a test run to assess the viability of adding Spain to a route that already links China with Germany five times a week. Those trains link Chongqing, the huge industrial city in south-west China, with Duisburg, and Beijing with Hamburg.

China is Spain’s biggest trading partner after the EU, with bilateral trade worth around £16bn. It is also Spain’s third largest source of imports, after Germany and France. About half of these imports are made up of mobile phones and clothing. The Spanish prime minister, Mariano Rajoy, was in China in September, where he signed deals reported to be worth more than £6.3bn.

A major advantage of the rail route is speed. The train took just three weeks to complete a journey that takes up to six weeks by sea. It is also more environmentally friendly than road transport, which would produce 114 tonnes of CO2 to shift the same volume of goods, compared with the 44 tonnes produced by the train – a 62% reduction.

However, the cargo had to be transferred three times during the journey as a result of incompatible rail gauges. The locomotive also had to be changed every 500 miles.

The service is being operated by InterRail Services and DB Schenker Rail and in Spain by DB’s Spanish offshoot, Tranfesa.

At the welcoming ceremony, the mayor of Madrid pointed out that a majority of the city’s 30,000 Chinese residents hailed from Zhejiang province. Relations between Spain and China took a dive earlier this year when a judge sought international arrest warrants for former president Jiang Zemin and four top officials in relation to alleged genocide in Tibet. The Spanish parliament took barely 10 days to throw out the case.