BAGHDAD - Wearing a camouflage suit and tie, Stephen Colbert took his show to Baghdad to entertain U.S. soldiers in Iraq. For openers, President Barack Obama appeared by video to thank the troops.

"You're welcome," the mock pundit answered.

"I wasn't talking to you," the president deadpanned.

To the roaring approval of hundreds of troops at Camp Victory, on the western edge of Baghdad, Colbert taped the first of four episodes of "The Colbert Report," in which he plays a pompous, blustering conservative TV host.

His first guest was the towering, bald Gen. Ray Odierno. When Obama and the U.S. commander suggested Colbert had to look like a soldier in order to be a soldier, the general took an electric razor to Colbert's perfectly parted cable-news coif.

The four shows are being taped in the domed marble hall at Saddam Hussein's former Al Faw Palace are to air this week starting Monday on Comedy Central.

Colbert has promoted the trip for weeks but only vaguely because the military urged caution. Instead, the pundit introduced segments with a jaunty theme: "Where in the World and When in Time is Stephen Colbert Going to Be in the Persian Gulf?"

At Camp Victory, Colbert was in typical, cluelessly egotistical form. He showed a clip pretending that he himself didn't know his destination until he got off the plane and somebody threw a shoe at him.

In another skit, he arrived at Fort Jackson, S.C., in a stretch limousine for "the full 10 hours" of basic training, then struggled to do push-ups and sit-ups while a drill sergeant barked at him.

And, concluding that the six-year war in Iraq must be over because nobody's talking about it anymore, Colbert said he would take it upon himself to make it official: "By the power vested in me by basic cable, I officially declare we have won the Iraq war!"

(To bolster his point, he offered a list of successes, including finding weapons of mass destruction -- "easier than we thought" -- and told the troops Obama should deploy them to General Motors.)

Odierno gently took issue with the self-sure pundit's suggestion the war had ended.

"We're not quite ready to declare victory," he said. "Things are moving forward but again, it's about bringing long-term stability."

Colbert, who sat at a desk propped up by sandbags painted to make up an American flag, responded by asking Odierno if he can bring long-term stability to the United States when he's done in Iraq.

The 45-year-old comedian, who travelled to Iraq from Kuwait on Friday on board a military transport plane, has said he decided make the trip when he noticed economic news coverage was eclipsing reports from Baghdad.

"It must be nice here in Iraq because I understand some of you keep coming back again and again," he joked. "You've earned so many frequent flier miles, you've earned a free ticket to Afghanistan."

He also joked about the economic crisis, congratulating one soldier in the audience who recently got his college degree while serving in Iraq for being the only 2009 graduate able to land a job.

Former Republican presidential candidate Senator John McCain, chided by Colbert throughout the campaign for his advanced age, made a surprise appearance, thanking the troops in a video for their service and reminding them to clean their muskets.

Many celebrities have visited Iraq to entertain the troops. But Colbert's series -- "Operation Iraqi Stephen: Going Commando" -- marks the first time anyone has broadcast a taped, non-news talk show fully produced and broadcast from Iraq as part of a USO tour.

USO senior official John Hanson said the production faced a major setback when a sandstorm grounded the crew on Saturday, forcing it to cancel plans for an outing.

Both the character and the real Colbert are ardent supporters of the troops. He has raised hundreds of thousands of dollars for the Yellow Ribbon Fund, which helps injured service members and their families, and is a board member of DonorsChoose.org, which is raising money for the education of children of military parents.

Colbert planned the trip after former Assistant Defence Secretary Bing West suggested it last summer following an interview "The Colbert Report." The show sent about 30 production workers, about a third of its regular staff, to Iraq.

Troops in the audience said they enjoyed Colbert's equal opportunity humour.

"Definitely the highlight was seeing him sacrifice his hair," said Spc. Ryan MacLeod, 35, of Greenville, S.C.