Based in Tanzania, it aimed to overthrow the Ugandan government of Idi Amin. Rwigyema returned to Tanzania and fought in the 1979 war during which Museveni's army, allied with the Tanzanian army and other Ugandan exiles, defeated Amin. After Amin's defeat, inspired by Rwigyema, Kagame and other Rwandan refugees pledged allegiance to Museveni, a cabinet member in the transition government. Kagame received training at the United States Army Command and General Staff College, Fort Leavenworth, Kansas. Former incumbent Milton Obote won the 1980 Ugandan general election. Museveni disputed the result, and he and his followers withdrew from the new government in protest. In 1981, Museveni formed the rebel National Resistance Army (NRA); Kagame and Rwigyema joined as founding soldiers, along with thirty-eight Ugandans. The army's goal was to overthrow Obote's government, in what became known as the Ugandan Bush War. Kagame and Rwigyema joined the NRA primarily to ease conditions for Rwandan refugees persecuted by Obote. They also had a long-term goal of returning with other Tutsi refugees to Rwanda; military experience would enable them to fight the Hutu-dominated Rwandan army. In the NRA, Kagame specialized in intelligence-gathering, and he rose to a position close to Museveni's. The NRA, based in the Luwero Triangle, fought the Ugandan army for the next five years, even after Obote was deposed in a 1985 coup d'état and the start of peace talks. In 1986, the NRA captured Kampala with a force of 14,000 soldiers, including 500 Rwandans, and formed a new government. After Museveni's inauguration as president he appointed Kagame and Rwigyema as senior officers in the new Ugandan army; Kagame was the head of military intelligence. In addition to their army duties, Kagame and Rwigyema began building a covert network of Rwandan Tutsi refugees within the army's ranks, intended as the nucleus for an attack on Rwanda. In 1989 Rwanda's President Habyarimana and many Ugandans in the army began to criticise Museveni over his appointment of Rwandan refugees to senior positions, and he demoted Kagame and Rwigyema. Kagame and Rwigyema remained "de facto" senior officers, but the change caused them to accelerate their plans to invade Rwanda.