In 111 BC, Chinese troops invaded Nam Việt and established new territories, dividing Vietnam into Giao Chỉ, Cửu Chân from modern-day Thanh Hoá to Hà Tĩnh; and Nhật Nam, from modern-day Quảng Bình to Huế. While the Chinese were governors and top officials, the original Vietnamese nobles (Lạc Hầu, Lạc Tướng) still managed some highlands.
In 40 AD, a successful revolt against harsh rule by Han Governor Tô Định, led by the noblewoman Trưng Trắc and her sister Trưng Nhị, recaptured 65 states (include modern Guangxi), and Trưng Trắc became the Queen (Trưng Nữ Vương). In 42 AD, Emperor Guangwu of Han sent his famous general Mã Viện to quell the revolt. After a torturous campaign, Ma Yuan defeated the Trưng Queen, who committed suicide. To this day, the Trưng Sisters are revered in Vietnam as the national symbol of Vietnamese women. Learning a lesson from the Trưng revolt, the Han and other successful Chinese dynasties took measures to eliminate the power of the Vietnamese nobles. The Vietnamese elites would be coerced to assimilate into Chinese culture and politics. However, in 225 AD, another woman, Triệu Thị Trinh, popularly known as Lady Triệu (Bà Triệu), led another revolt which lasted until 248 AD.
During the Tang dynasty, Vietnam was called Annam (Giao Châu), until the early 10th century AD. Giao Chỉ (with its capital around modern Bắc Ninh province) became a flourishing trading outpost receiving goods from the southern seas. The "History of Later Han" (Hậu Hán Thư, Hou Hanshu) recorded that in 166 AD the first envoy from the Roman Empire to China arrived by this route, and merchants were soon to follow. The 3rd-century "Tales of Wei" (Ngụy Lục, Weilue) mentioned a "water route" (the Red River) from Jiaozhi into what is now southern Yunnan. From there, goods were taken overland to the rest of China via the regions of modern Kunming and Chengdu.
At the same time, in present-day central Vietnam, there was a successful revolt of Cham nations. Chinese dynasties called it Lin-Yi (Lin village). It later became a powerful kingdom, Champa, stretching from Quảng Bình to Phan Thiết (Bình Thuận).
In the period between the beginning of the Chinese Age of Fragmentation to the end of the Tang Dynasty, several revolts against Chinese rule took place, such as those of Lý Bôn and his general and heir Triệu Quang Phục; and those of Mai Thúc Loan and Phùng Hưng. All of them ultimately failed, yet most notable were Lý Bôn and Triệu Quang Phục, whose Anterior Lý Dynasty ruled for almost half a century (544 AD to 602 AD) before the Chinese Sui Dynasty reconquered their kingdom Vạn Xuân.