 Later in his youth, he was put under the guardianship of the pagoda's new headmaster Lý Vạn Hạnh, who was a very well respected cleric during the Anterior Lê Dynasty era, he came to the royal capital Hoa Lư to be religious advisor for the Lê royal court.He was gradually promoted from a minor official to a prominent post of the imperial government and was ultimately bestowed with the title “Tả Thân Vệ Điện Tiền Chỉ Huy Sứ” meaning "The Commander of the Palace's Left Flank", which was one of the most important positions within the imperial guards.In 1009, Lê Ngoạ Triều, the last monarch of the Anterior Lê Dynasty died under the wrath of the people because of his brutality and cruelty he brought onto them during his reign.