Canada's military efforts in Afghanistan will end this month, with the withdrawal of the last 100 soldiers from Kabul, where they had been wrapping up training of Afghan National Security Forces.

Canada’s involvement included efforts in diplomacy, education, women’s rights and even dam building. The five years of heavy combat cost the lives of 158 Canadian soldiers, two consultants, one diplomat and one journalist.

With security deteriorating in many rural areas of Afghanistan, a number of foreigners have faced tighter security measures. As the country approaches the presidential elections next month, authorities expect to see more violence and instability.

Against a backdrop of heightened security, the Canadian flag will be formally lowered on Wednesday and Canadian troops will leave Afghanistan by the end of the week.

Here's a timeline of Canada's role in Afghanistan:

October 2001: Following the 9-11 attacks in the United States, the UN Security Council adopts a resolution supporting efforts to root out terrorism in Afghanistan. On Oct. 8, a day after the U.S. begins operations against al Qaeda and the Taliban in Afghanistan, Canada announces that it will contribute sea, land and air forces to the operation.

October 2002: Canadian troops deploy to Afghanistan as part of U.S.-led Operation Enduring Freedom.

July 2003: Operation Athena begins: Then-Brigadier-General Peter Devlin arrives in Afghanistan for a six-month tour in command of ISAF’s Kabul Multi-National Brigade. Canadian Forces begin deploying to Kabul to take part in a NATO-led mission to help maintain security in Kabul and the surrounding areas.

August 2003: Canada opens its embassy in Kabul.

August 2005: Canada assumes leadership of the Kandahar Provincial Reconstruction Team and the Canadian Armed Forces in Kabul begin to transition to Kandahar Province.

January 2006: CAF members begin combat operations in Kandahar. At its height, nearly 3,000 CAF members were deployed at any one time in Kandahar.

August 2007: A stretch of Highway 401 running from Trenton, Ont., to Toronto is officially renamed the Highway of Heroes in remembrance of Canada's fallen soldiers.

February 2008: Parliament votes to extend the combat mission in Kandahar to 2011.

June 2008: Additional Canadian troops are deployed to Kandahar following a prison break that freed about 400 Taliban fighters. 

November 2009: A senior diplomat tells a House of Commons committee that Afghan prisoners transferred by Canadians to local authorities in Kandahar were all likely tortured

March 2010: Documents show the Canadian Security Intelligence Service (CSIS) played a role as interrogators of captured Taliban fighters.

July 2010: At the Kabul Conference, the international community and the Government of Afghanistan agree to the country's transition plan that will see Afghans assume leadership of security, governance and economic development.

November 2010: Ottawa announces Canada's role in Afghanistan will continue until 2014.

May 2011: Canada contributes the second-largest contingent to the NATO Training Mission-Afghanistan, which delivers training and professional development support to the national security forces in the country. 

July 2011: Canada ends its combat mission in Kandahar province. A task force arrives in Afghanistan to prepare and ship vehicles, equipment and material elsewhere in Afghanistan or back to Canada; Canada begins a new mission based in Kabul that focuses on investing in Afghan children and youth, advancing security and human rights, promoting diplomacy and delivering humanitarian assistance.

September 2011: CSIS is cleared of wrongdoing in connection with the abuse of Afghan detainees.

November 2011: Tim Hortons closes up shop in Kandahar. In the outlet's five-and-a-half years in business it served up about four million cups of coffee, three million donuts and 500,000 iced coffees.

May 2012: Prime Minister Stephen Harper announces Canada's military mission in Afghanistan will come to a firm, final end on March 31, 2014.

June 2012: The Military Police Complaints Commission releases its long-awaited Afghan detainees report, concluding that complaints its officers mishandled allegations of post-transfer torture were "unsubstantiated."

June 2013: The final rotation of CAF members to Afghanistan begins deploying, including the mission closure team to pack-up and recover equipment to be returned to Canada.

March 2014: Canadian training troops will be out of Afghanistan by mid-March, with a formal lowering of the flag on Wednesday, March 12.