United States president Barack Obama has visited US troops while on an unannounced whistle-stop night visit to Afghanistan for urgent talks with president Hamid Karzai.

On Mr Obama's first trip to Afghanistan as president, he told troops: "There is no visit I consider more important than the visit I am making right now."

The official itinerary had the president having a quiet weekend at Camp David with his family after a frantic week, first with his healthcare victory and capped off with a new arms reduction treaty with Russia.

But instead he secretly boarded Air Force One for an overnight flight to Bagram Airfield.

From there he transferred to a helicopter to fly into Kabul for talks at the presidential palace.

Mr Karzai was only told on Friday, Australian time, that Mr Obama was coming.

Mr Obama also met the US and NATO commander Stanley McChrystal before addressing troops.

"I know that sometimes, when you're watching TV, the politics may look a little messy and people are yelling and hollering Democrats this and Republicans that," he told the assembled troops.

"I want all of you to understand there's no daylight when it comes to supporting you. There's no daylight when it comes to supporting our troops."

He thanked coalition and Afghan forces for their sacrifices.

"We are going to disrupt and dismantle, defeat and destroy Al Qaeda and its extremist allies. That is our mission," he said.

Washington invitation

The two leaders had a short meeting and the American leader invited his Afghan counterpart to Washington in May.

After Mr Karzai's controversial re-election late last year, White House officials say Mr Obama wanted to press the Afghan leader to do more to promote good governance and tackle corruption and narco-traffickers who are providing funding for insurgents.

For his part, Mr Karzai is looking for reassurances about the number of civilian casualties caught up in the fighting.

Commentators such as longtime defence writer Jamie McIntyre say the US administration wants the Afghan leader to move much faster.

"The clock is ticking and President Obama really wants to put the pressure on Hamid Karzai to start doing some of the things that would help ensure success after US troops begin to leave sometime next year, according to the president's goal," he said.

"There are two problems with this strategy. One is the things that they're asking President Karzai to do - which is strengthen the institutions in the country, wipe out corruption, take more action in the drug war because Afghanistan in some places is in danger of becoming a narco state - are the same things they've been asking him to do all along.

"The second problem is that the reason the clock is ticking is simply because President Obama has announced a goal to begin withdrawing troops next year."

Casualties rising

The trip comes with American casualties in Afghanistan rising sharply as US troops press Taliban militants in the south.

US troop numbers will increase over the coming months to nearly 100,000.

Retired Lieutenant Colonel Bob Maginnis says it is part of a broader strategy to strengthen partnerships in the region and isolate Iran.

"The fact is that the president is bringing the spotlight to Afghanistan at a critical time," he said.

"Keep in mind this past week that General Kayani - the military commander of Pakistan next door, which is an absolutely critical ally in this effort - he was in the Pentagon, he was all over Washington.

"And they've been very helpful to us, so I think this [visit] is saying thanks to the Pakistanis for helping us, but Iran watch out because we know you're not helping, and by the way President Karzai, we're going to be there but you've got to do your job."

The US administration is also concerned about losing public support for the war if the governance problems in Afghanistan continue.