The French missionary priest Pigneau de Behaine played a role in Vietnamese history towards the end of the 18th century by befriending Nguyễn Ánh, the most senior of the ruling Nguyễn lords to have escaped the rebellion of the Tây Sơn brothers in 1777. Becoming Nguyễn Ánh's loyal confidant, benefactor and military advisor during his time of need, he was able to gain a great deal of favor for the Church. During Nguyễn Ánh's subsequent rule as Emperor Gia Long, the Catholic faith was permitted unimpeded missionary activities out of his respect to his benefactors. By the time of the Emperor's accession in 1802, Vietnam had 3 Catholic dioceses with 320,000 members and over 120 Vietnamese priests.