Tony Blair has paid tribute to British troops after flying into Iraq for a surprise pre-Christmas visit.
Mr Blair told them: "I just want you to know how grateful we are for the work you are doing here."
He said they were helping to build democracy and they could return home when Iraqi forces were up to strength.
Mr Blair was upbeat about troop withdrawal in 2006 but did not set any timetable, said the BBC's James Landale who was travelling with him.
The prime minister said the situation had "changed completely" since he visited Iraq last year and that it was the government's intention to "draw down our forces".
"He (Tony Blair) and his officials have been more upbeat about the possibility of beginning the process of withdrawing the troops from Iraq," Mr Landale said.
He said Mr Blair rejected setting an artificial deadline, but said what he failed to do was "dismiss out of hand" remarks by a UK general a few weeks ago that troops could start to be withdrawn in six months time.
Mr Blair said: "It all depends on the mission being fulfilled ... this is to have the political process completed and building up the Iraqi capabilities ..."
He added: "But there's no reason ... if everything goes to plan ... we want to draw down our forces, we do not want to keep people here any longer than we need to."
Mr Blair's spokesman said no consideration could be taken about troop numbers until at least after the new government had been formed and the spring provincial elections are held in Iraq.
US Defense Secretary Donald Rumsfeld is also making an unannounced visit to Iraq to meet military commanders and troops. Mr Rumsfeld flew to Baghdad from Afghanistan, amid signs Washington is planning further troop cuts.
His arrival in Iraq came as Sunni Arab and secular parties in Iraq threaten to boycott the country's new parliament, complaining that last week's elections were marred by fraud.
Mr Blair, whose visit had been kept secret, touched down in Basra in an RAF Hercules from Kuwait. He then transferred by helicopter to the Shaiba logistics base, where he addressed some of the 4,000 troops based there from the back of a low-loader truck.
He told them: "I know it's particularly tough being away from your families at Christmas and New Year.
"I just want you to know how grateful we are for the work you are doing here. However tough it is, I hope you have some sense of how important it is."
He said 10 million Iraqis had voted in recent elections.
"The important thing is to try and help this country become the democracy its people want it to be," Mr Blair told the troops.
That would be done by providing the security which allowed the Iraqi forces to build up their own strength "and then of course we can eventually draw down our own capability".
"The importance of this is probably greater today than it has ever been," said Mr Blair.
"Because, if Iraq does stabilise and become a democracy, then the region is more safe, our own country is more safe, because international terrorism will have been dealt a huge blow.
"If we manage to defeat the terrorism here, we will have dealt it a blow worldwide. I know how dangerous it is sometimes, because we have lost good colleagues here - and it is tough, I know, sometimes."
But whatever the dangers "you can look back at this time and you can be very, very proud of what you have done", the prime minister told the troops.
Mr Blair met top US and British defence officials, including Gen George Casey head of coalition forces, during his flying visit - his fourth trip to Iraq since the US-led invasion.
Former British Ambassador to Baghdad, Sir Jeremy Greenstock, has said a total withdrawal of coalition troops was "some way away", but that he expected numbers to begin reducing by the end of 2006.
"If Iraq goes well you can draw down to half of that (the total coalition troop numbers) by the end of 2006," he told BBC Radio 4's World at One.
"If things don't go well, the coalition should still be in six figures."
The UK has 8,500 servicemen and women stationed in Iraq.