By autumn 1989 the regime was barely clinging to power. On December 20, US troops began an invasion of Panama. Under codename Just Cause Operation they achieved their objectives and began withdrawal on December 27. The US was obligated to return control of the Canal to Panama on January 1 due to a treaty signed decades before. Endara was sworn in as President at a US military base on the day of the invasion. Noriega served a 40-year sentence for drug trafficking before his eventual death on May 29, 2017.