Relations between Somalia and China starts well before the medieval times. Through trade, they established good relations. Giraffes, zebras and incense were exported to the Ming Empire of China, which established Somali merchants as leaders in the commerce between the Asia and Africa, and in the process influenced the Chinese language with the Somali language and vice versa. The Chinese exported celadon wares, spices and muskets in return for horses, exotic animals and ivory. The prominent Hui-Chinese explorer, mariner, diplomat and fleet admiral, Zheng He, arrived in his fourth and fifth voyage to the Somali cities of Mogadishu, Zeila, Merca and Berbera. Sa'id of Mogadishu a Somali explorer travelled to China in the 14th century, when China was ruled by the Yuan Dynasty, and noted the trading communities of the Chinese ports and cities.
Cold war era 
The Sino-Soviet split had a large influence on China's relations with African countries; as early as 1964, Somalia was described as the "first major area of Sino-Soviet Rivalry in Africa". When the Somali side expelled Soviet representatives in late 1977, China agreed to take over many of the aid projects started by them.
Early modern era 
Mohamed Hassan Said, who had become the Somali ambassador to China in 1988, found himself stranded in Beijing without a government to serve. No longer receiving a salary and lacking the funds to travel out of the country, he and his family survived on handouts from embassies of other Muslim countries. He continued to live in Beijing for the next 18 years, and his children attended university in China. The Washington Post described him as China's "saddest foreign resident." Despite the lack of a central government in Somalia, the Chinese government nevertheless regarded Said as the legitimate Somali ambassador, and continued to invite him to diplomatic functions.
In 2006, Said was finally replaced as ambassador by Mohamed Awil, who also received no salary. Awil represented the Transitional Federal Government of Somalia, and spoke out in favor of Chinese naval intervention to fight piracy off the coast of Somalia.
Present day 
Despite the departure of most Chinese nationals from Somalia in 1991, the two countries maintained a small trading relationship; total trade volume in 2002 was US$3.39 million, with Somalia exporting US$1.56 million of goods to China and importing $1.83 million. In July 2007, the China state-owned oil company CNOOC signed an agreement with the Somali government to search for oil in the Mudug region of the semi-autonomous state of Puntland; a competing oil company estimated the total reserves in Puntland could amount to five to ten billion barrels of oil. However, an unnamed diplomat from a Western country stated that the Somali government had signed similar deals with other countries, which could bring CNOOC into conflict with foreign competitors over exploration and drilling rights.
- "China and Somalia". Ministry of Foreign Affairs of the People's Republic of China. 2003-10-12. Retrieved 2007-06-11.
- "Somalia to Trade With China". The New York Times. 1963-06-09. Retrieved 2007-11-06.
- Colour, confusion and concessions: the history of the Chinese in South Africa, 2005, Melanie Yap,Dianne Leong Man, page 3
- East Africa and its Invaders pg.37
- Zheng He's voyages down the western seas - Page 42, 福建省新闻办公室
- Schwartz, Harry (1964-09-06). "Communists Competing in Africa". The New York Times. Retrieved 2007-11-06.
- "Chinese to Increase Aid to Somalia". The Washington Post. 1987-04-21. Retrieved 2007-11-06.
- Chinese Foreign Ministry (October 10, 2006). "FOCAC Beijing Summit: Somali".
- Richburg, Keith (1997-01-01). "Somali envoy is adrift in China". Austin American-Statesman. Retrieved 2007-11-06.
- "Embassy staff visit exhibition marking 60th anniversary of victory of anti-Fascist War". People's Daily. 2005-07-12. Retrieved 2007-11-06.
- Blanchard, Ben (June 14, 2006). "China start for Somalia". Reuters.
- Zhang, Haizhou (2008-12-17). "Somalia welcomes Chinese naval presence". China Daily.
- Li, Xiaokun (2009-12-29). "Help us build a coast guard, pleads Somali diplomat". China Daily.
- Jopson, Barney (2007-07-13). "Somalia oil deal for China". Financial Times. Retrieved 2007-11-06.