Prime Minister Stephen Harper made a surprise trip to Afghanistan on Monday for what is likely the last time, as Canada winds down its combat operations and prepares to devote its attention to training Afghan soldiers and police personnel.

Harper, on his fourth trip to Afghanistan, was accompanied by Defence Minister Peter MacKay and Chief of Defence Staff Gen. Walt Natynczyk, as well as Calgary Flames captain Jerome Iginla and other NHL players.

The prime minister spent a few hours in the country, capping his visit with a speech to more than 500 Canadian soldiers at Kandahar Airfield.

"You have been courageous warriors, so you are also compassionate neighbours," Harper told the troops.

"You have done exceptionally well. On behalf of all Canadians, I salute you."

Canadian Press reporter Murray Brewster said Monday afternoon that in his half-hour address, Harper summed up Canada's combat mission and told the soldiers that it was launched with good intentions.

"What he did say was that when Canadian troops came into Afghanistan, it was because Afghanistan was a threat to the rest of the world," Brewster told CTV News Channel in a telephone interview from Kandahar. "And by their service in Kandahar, the prime minister said that Canadian troops have ensured that Afghanistan is no longer a threat to the rest of the world, because it had harboured al Qaeda. And in that sense he delivered almost a mission accomplished speech."

Harper had spent the weekend in Greece following the G8 summit in France late last week. Brewster said that an increased security presence at Kandahar Airfield tipped off reporters that a dignitary was set to pay a visit.

"It was a surprise for many of the troops on the base," Brewster said. "A lot of them were surprised to see the prime minister glad-handing around this evening. It was a very welcome surprise for a lot of them."

During his visit, Harper was flown by helicopter to a forward operating base in the Panjwaii District. Harper also toured a former al Qaeda compound where Osama bin Laden spent some time in the 1990s. The site has been redeveloped, with the help of Canadian aid, into an agricultural area of wheat and barley fields known as Tarnack Farms.

The site is also where the first four Canadians to die in Afghanistan were killed by friendly fire in 2002.

Osama bin Laden can be seen at the compound in video footage, talking to recruits that include some of the hijackers who were part of the Sept. 11, 2001 terrorist attacks on the United States.

"The vicious Taliban regime bludgeoned its own citizens, but welcomed the world's worst killers -- men so immersed in their own evil that they believed their appalling ambitions to be nothing less than the will of God," Harper told the soldiers.

The prime minister also laid a wreath at a monument to fallen Canadians.

From combat to training

The prime minister's visit corresponded with the release of more information about Canada's transition to a training mission, which was announced late last year. The federal government said last November that 950 soldiers would remain in the country to train the Afghan army and police personnel after the combat mission ends in July.

Reporters were told Monday that, although soldiers are still out conducting patrols on the battlefield, the first 371 trainers are now on the ground in Afghanistan, with the rest due to arrive over the next several months.

Harper told reporters that Canadian training personnel will not be out on the battlefield, but instead will conduct their work in classrooms.

But he conceded that violence is still a threat in Afghanistan.

"It is a violent and dangerous country," Harper said. "There can be attacks that come to the base and from within the base. Obviously we expect these things to be of a significantly lower risk than that we've experienced over the past several years."

Col. Peter Dawe, deputy commander of the training mission, said the army is setting in place policies that will reduce the risk to Canadian soldiers. For the most part, troops will live and work in the same compound, and limit their movement around the country.

"But in the end of the day it's a difficult environment," Dawe said.

"Our troops are well-trained. They're prepared for it. They're going into this with eyes wide open. For the most part, we're talking about combat veterans here."

The bulk of the 950 trainers will be based in Kabul, but 90 medical and military police advisers will be stationed in the northern city of Mazar-e-Sharif. Fifteen soldiers will work at NATO's regional training centre in Herat, in the west.