The military of the Nguyễn dynasty (Vietnamese: Quân thứ; Chữ Nôm: 軍次) were the main military forces of the Nguyễn dynasty from 1802 to August 1945 when it was dismantled by the August Revolution. The Nguyễn military force was initially formed by Nguyễn Hoàng as a division of the of the Revival Lê dynasty in 1558 starting out with 3000 soldiers. During this period it was the military forces of the domain of the Nguyễn lords and commonly fought the Trịnh lords who controlled northern Vietnam. During the Tây Sơn Rebellion it was expelled out most of the county by the Tây Sơn dynasty. After the exiled Nguyễn Phúc Ánh returned and defeated the Tây Sơn rebels he crowned himself as the Gia Long Emperor and the Nguyễn military became the national military of Vietnam.