Bush arrived in Afghanistan at 5.30 a.m. (00:30 GMT), and was met by Gen. David McKiernan, the U.S. commander of NATO-led troops in the war-ravaged Central Asian state. He then addressed over a thousand U.S. troops at Bagram air base.
"Afghanistan is a dramatically different country than it was eight years ago," Bush told the troops, addressing them in a giant hanger. "We are making hopeful gains."
He also said that he supported president-elect Barack Obama's pledge to increase troop numbers in Afghanistan. There are currently 65,000 foreign troops in Afghanistan, 32,000 of them from the U.S. Washington led a 2001 invasion of the country to topple the hard-line, and increasingly revitalized, Taliban Islamic movement.
Bush then traveled by helicopter to the capital, Kabul, to meet Afghan leader Hamid Karzai in the presidential palace.
"I and the Afghan people are very proud and honored to the depths of our hearts to have President Bush with us here today," Karzai said.
"I told the president, 'You can count on the United States,"' Bush said after the meeting. "'Just like you've been able to count on this administration, you'll be able to count on the next administration as well."'
Bush's dawn visit trip to Kabul came as an unexpected tag-on to his visit to Iraq. In Baghdad, Bush told Iraqi President Jalal Talabani that the war, which began when U.S.-led troops invaded the country in 2003 to topple Saddam Hussein, was not yet over.
"The work hasn't been easy but it's been necessary for American security, Iraqi hope and world peace," he said.
Talabani called Bush "a great friend for the Iraqi people, who helped us liberate our country".
Bush later signed a security pact with Iraqi Prime Minister Nouri Maliki under which U.S. troops will be withdrawn from Iraq by the end of 2011. They are to withdraw initially from Iraqi cities by June 2009.
However, Bush's brief visit to Iraq was not all smiles. During a press conference with Maliki, a correspondent for the Cairo-based al-Baghdadiya TV hurled his shoes at the U.S. president, shouting in Arabic, "this is a farewell kiss from the Iraqi people, dog" and "this is for the widows and orphans and all those killed in Iraq."
He was then overpowered by security personnel and taken away.
Bush, who dodged both shoes, said "I don't know what the guy's cause is." He later commented that, "If you want the facts, it's a size 10 shoe that he threw"
Showing the soles of shoes is considered an insult in Arabic culture. In 2004, Libyan leader Muammar al-Qaddafi pointed the sole of his shoes towards then-British prime minster Tony Blair during talks in Libya. The gesture was interpreted in the Arab world as "the worst of all insults."