Defense Secretary Robert Gates flew into Baghdad on Monday, preparing to hand command of the war in Iraq to a new general charged with maintaining better security while U.S. troop numbers fall. Gates is making his eighth visit to Iraq since he took over at the Pentagon in December 2006. On Tuesday he will preside over a ceremony to transfer command of U.S.-led forces in Iraq to Lieutenant-General Ray Odierno from General David Petraeus, whose term was marked by the deployment of 30,000 extra U.S. troops and a substantial decline in violence. "The challenge, I think, for General Odierno is: How do we work with the Iraqis to preserve the gains that have already been achieved, expand upon them, even as the numbers of U.S. forces are shrinking," Gates told reporters on his plane. Odierno, who served as the number 2 U.S. commander in Iraq for 15 months until February, will be promoted to full general on Tuesday. President George W. Bush announced last week a modest cut in U.S. forces in Iraq, saying 8,000 troops would come home by February. That will leave 138,000 troops in the country. Many troops who were scheduled to replace those departing from Iraq will now head to Afghanistan, where insurgent violence has grown dramatically in the past two years. Gates last week said the war in Iraq had entered its "endgame" but he urged the next U.S. president to continue a cautious approach to troop cuts.