Human habitation in Shenzhen dates back to ancient times. The earliest archaeological remains so far unearthed are shards from a site at Xiantouling on Mirs Bay, dating back to 5000 BC. From the Han Dynasty (third century BC) onwards, the area around Shenzhen was a center of the salt monopoly, thus meriting special Imperial protection. Salt pans are still visible around the Pearl River area to the west of the city and are commemorated in the name of theYantian container terminal (盐田, meaning “salt fields”).

The settlement at Nantou was the political center of the area from early antiquity. In the year 331 AD, six counties covering most of modern south-eastern Guangdong were merged into one province or “jun” named Dongguan Jun with its center at Nantou. As well as being a center of the politically and fiscally critical salt trade, the area had strategic importance as a stopping off point for international trade. The main shipping route to India, Arabia and the Byzantine Empire started at Canton. As early as the eighth century, chronicles record the Nantou area as being a major commercial center, and reported that all foreign ships in the Canton trade would stop there. It was also as a naval defense center guarding the southern approaches to the Pearl River.

Shenzhen was also involved in the events surrounding the end of the Southern Song Dynasty (1276–79). The Imperial court, fleeing Kublai Khan’s forces, established itself in the Shenzhen area and the last Emperor died strapped to the back of his chief Minister who preferred suicide to the possibility of the Emperor being captured and bringing shame to the dynasty. In the late 19th century the Chiu or Zhao (Zhao was the Song Imperial surname) clan in Hong Kong identified the Chiwan(in Chinese: 赤湾) area as the final resting place of the Emperor and built a tomb to him. The tomb, since restored, is still in Chiwan.

Earliest known ancient records that carried the name of Shenzhen date from 1410 during the Ming Dynasty. Local people called the drains in paddy fields “zhen” (). Shenzhen (深圳) literally means “deep drains” as the area was once crisscrossed with rivers and streams, with deep drains within the paddy fields. The character is limited in distribution to an area of South China with its most northerly examples in Zhejiang Province which suggests an association with southwards migration during the Southern Song Dynasty (12th and 13th centuries). The County town at Xin’an in modern Nanshan dates from the Ming Dynasty where it was a major naval center at the mouth of the Pearl River. In this capacity it was heavily involved in 1521 in the successful Chinese action against the Portuguese Fleet under Fernão Pires de Andrade. This battle, called the Battle of Tunmen, was fought in the straits between Shekou and Lintin Island.

Shenzhen was singled out to be the first of the five Special Economic Zones (SEZ). It was formally established in 1979 due to its proximity to Hong Kong. The SEZ was created to be an experimental ground for the practice of market capitalism within a community guided by the ideals of “socialism with Chinese characteristics”.

Shenzhen eventually became one of the largest cities in the Pearl River Delta region, which has become one of the economic powerhouses of China as well as the largest manufacturing base in the world.

In November 1979, Shenzhen, then known as Bao’an County (宝安县), was promoted to prefecture level, directly governed by Guangdong province. In May 1980, Shenzhen was formally nominated as a “special economic zone”, the first one of its kind in China. It was given the right of provincial-level economic administration in November 1988.

For five months in 1996, Shenzhen was home to the Provisional Legislative Council and Provisional Executive Council of Hong Kong.