The civil war concerning the Lê-Trịnh and Mạc dynasties ended in 1592, when the army of Trịnh Tùng conquered Hanoi and executed king Mạc Mậu Hợp. Survivors from the Mạc royal family members fled for the northern mountains inside the province of Cao Bằng and ongoing to rule there right until 1677 when Trịnh Tạc conquered this v