After Đinh Liễn was able to escaped and returned to Hoa Lư, Đinh Bộ Lĩnh went to convinced Trần Lãm, another warlord who occupied Bố Hải Khẩu (modern-day Thái Bình province) as his ally. When king Ngô Xương Văn was killed during a battle in 965 and the country fells into chaotic civil wars between warlords, Đinh Bộ Lĩnh and Đinh Liễn commanded their army subdued the highland tribes, then took capital Cổ Loa in the same year. Two years later, he defeated or had all the warlords submitted, pacified the country at the age of 43. In 967, Bộ Lĩnh assigned his son Liễn the title "King of Nam Viet". The only survivor of the previous Ngô family, Ngô Nhật Khánh submitted to Bộ Lĩnh, and he gave one of his own daughters, Princess Phất Kim in marriage with Nhật Khánh. After that, Ngô Nhật Khánh took his wife and fled to the south. He scolded her face and hatred of her father, and he went exiled in Champa.