British Prime Minister Gordon Brown traveled to the main British military base in southern Afghanistan on Monday to boost the spirits of troops serving on the front line of an increasingly deadly fight against Taliban militants.

Brown's visit, the second stop on a trip that also took him to Iraq, comes amid a successful NATO and Afghan operation to retake a Taliban-controlled town, Musa Qala, in the area where British troops operate.

Afghan troops aided by British and U.S. forces entered Musa Qala on Monday for the first time since last February, when Taliban militants overran it following a failed peace deal between fighters and Afghan elders that had been backed by Britain.

Brown met with about 150 British troops at Camp Bastion in Helmand province, thanking them for their "patriotic service." He then traveled to the capital, Kabul, to meet with President Hamid Karzai.

"I want to thank every one of you for what you have done in what is the front line against the Taliban," Brown told the soldiers.

"It is one of the most difficult of tasks. It is the most testing of times and it is one of the most important of missions because to win here and to defeat the Taliban and make sure we can give strength to the new democracy of Afghanistan is important to defeating terrorism all around the world," he said.

Brown's visit to Iraq on Sunday signaled the start of what Britain hopes will be the transition from a military mission there to one aimed at aiding Iraq's economy and providing jobs. His speech was met with enthusiastic applause and cheers by British troops stationed there.

His speech in southern Afghanistan, by contrast, was more subdued, as was the resulting applause, perhaps reflecting the serious fight that British soldiers find themselves in there.

"We have an operation ongoing in Musa Qala, we've just had people die, so it's a different tempo," said Lt. Andy McLachlan, from Exeter in southwest England.

McLachlan said it was good that Brown visited. He said the British people "have really gotten behind us."

At least 40 British soldiers have been killed in Afghanistan this year and 86 have died in the country since 2001.

This year has been the deadliest since the U.S.-led invasion in 2001. More than 6,200 people have been killed in insurgency-related violence, according to an AP tally of figures from Western and Afghan officials.