The civil war among the Lê-Trịnh and Mạc dynasties led to 1592, when the military of Trịnh Tùng conquered Hanoi and executed king Mạc Mậu Hợp. Survivors from the Mạc royal family fled into the northern mountains from the province of Cao Bằng and continued to rule there until eventually 1677 when Trịnh Tạc conquered this last M