(CNN) -- After more than 12 years and under a blanket of security in Kabul, Canadian military operations in Afghanistan came to a formal close this week. As the Canadian flag was lowered at NATO headquarters in a low-key ceremony, officials looked back at a mission that began in 2001 and cost the country 158 military lives.
Two Canadian civilian contractors, a diplomat and a journalist also died during Canada's involvement in Afghan operations.
Canadian troops were active in the restive Kandahar province in the south of the country, dubbed the "home of the Taliban," from 2006 and have latterly been involved in training Afghan National Security Forces in the capital, Kabul.
Over 40,000 Canadian troops have been rotated in and out of the country since NATO's ISAF operations began -- the largest deployment since the end of the Second World War. The remaining 100 Canadian military personnel will leave the country by the end of the week.
In a statement released to mark the occasion, Minister of National Defence Rob Nicholson said, "From the first arrival of our ships in the Persian Gulf, to our combat and leadership roles in Kandahar Province, to our most recent training operation in Kabul, the contribution of the CAF will be honored by Canadians as we express our heartfelt thanks for the strength of this commitment."
Major-General Dean Milner, commander of the NATO Training Mission - Afghanistan led 3000 Canadian troops in Kandahar from September 2010 to July 2011 and said that his troops had made a real difference in the troubled region.
"I think that we held the fort well and I think we enabled that part of the country to improve and take off and the progress has been ... it's been night and day," he said in a video looking back at Canadian involvement, prepared by the ISAF.
"I think that we can feel proud about our accomplishments down in Kandahar."
The Canadian contingent has been credited for the development of a network of roads connecting key districts in the province, amongst other key infrastructure and civic work.
Milner also recognized the "sacrifices" made by Canadian troops during their deployment.
Tributes to the the Canadian military efforts also came from allies on the ground.
"The Canadian Armed Forces have been a reliable and significant partner in the success of the ISAF mission," US General Joseph Dunford, ISAF commander, said in a statement.
The ISAF also reports that the Canadian government has committed to spending $330 million to help fund Afghan security forces.
The withdrawal comes as part of a larger commitment by NATO to remove all combat troops from the country by the end of 2014, although there are ongoing negotiations over an extended advisory role for the security organization.
The withdrawal coincides with China's apparent willingness to cooperate internationally on matters of security. During the National People's Congress in Beijing, Foreign Minister Wang Yi said that China will work with regional neighbors -- including Afghanistan, with which it shares a short border -- to "resolutely fight against all terrorist forces."