John McCain, the Republican candidate for the 44th US Presidency, yesterday warned that al Qaeda was "on the run but not defeated" in Iraq as he praised the long service and sacrifice of British troops in the region.

His stopover in London coincided with 60 anti-war campaigners marking the fifth anniversary of the Iraq invasion with a minute's silence outside the gates of Downing Street and the delivery of a letter to Gordon Brown, demanding a public inquiry into the conflict.

After his talks with the Prime Minister, the 71-year-old senator and Vietnam veteran carefully avoided being drawn into the hot domestic issue of how long UK soldiers would remain in Basra. "I believe that decision is a matter for the British Government and people," he told reporters.

However, the incoming Republican candidate for the presidency made clear his commitment to the US mission and warned that any premature withdrawal would risk handing victory to the terrorists. "The fact is," he declared, "al Qaida is on the run. They are not defeated. We're going to have to continue training the Iraqi military and do what we have been doing if we are going to achieve a stable situation in Iraq."

Mr McCain, who is on a week-long tour of Europe and the Middle East as a member of the Senate Armed Services Committee, expressed appreciation for the "long-standing and unique relationship" between Britain and America based on "common values and common efforts". He praised the "long service and sacrifice" of British troops in both Iraq and Afghanistan while acknowledging the public's anxiety at the slow pace of progress.

"I fully appreciate that British public opinion has been frustrated by sometimes our lack of progress in both areas. All I can do is express my gratitude to the British Government and people, especially the brave young people who are serving."

Mr McCain spent 45 minutes talking to Gordon Brown on issues ranging from Iraq and Afghanistan to climate change and reforming international institutions. The Prime Minister's spokesman described the discussions as "constructive". Later, the American politician went to the Commons to have a meeting with David Cameron and some of his Shadow Cabinet. The Conservative leader said the discussions were "fascinating and very productive".

On UK troop numbers, No 10 said that as and when there was an update the Ministry of Defence would make it - a regular turnover of soldiers was due later this spring - but the PM's spokesman stressed that any decision on them would be made on the basis of military advice and the conditions on the ground.

David Miliband, the Foreign Secretary, acknowledged British troop numbers in southern Iraq were on a "downward trajectory". Last year, the Prime Minister announced the British force, currently numbering around 4100, would be cut to 2500 "from the spring" of this year, with the possibility of further cuts to follow.

Mr Miliband refused to comment on reports that that target would not be met but insisted troop numbers were on the way down. Earlier, he claimed the war was "a remarkable victory" but acknowledged the peace had been "much more difficult than people expected".

With Senators Barack Obama and Hillary Clinton, the two Democrat hopefuls in the race to the White House, committed to withdrawing US troops, Mr McCain acknowledged Iraq would be "a very big issue in this campaign as to whether we withdraw and have al Qaeda win and announce to the world that they have won".

The Republican politician claimed the American public was beginning to see last year's troop surge in Iraq as a success. He insisted it was possible to build "a stable, functioning - not very effectively, but functioning - democracy" in Iraq, noting: "I believe if we had done what others were advocating, it would have had disastrous consequences for the United States, chaos and further sacrifice on the part of the American people."

The Arizona senator backed Mr Brown's decision to meet the Dalai Lama, the exiled Tibetan leader, saying: "I am very disturbed about what is happening in Tibet.

"I strongly urge them (the Chinese) to respect the rights of the people who are demonstrating there."