Australia will pull its remaining 80 troops from Afghanistan by September, marking the end of its longest involvement in a war.
This is in line with the announcement by United States President Joe Biden of America's withdrawal.
An emotional Prime Minister Scott Morrison read out the names of the 41 Australians who died since the conflict began after the September 11 2001 terrorist attacks in the US.
Biden said this week it was time to end the "forever war". The US currently has about 2,500 troops in Afghanistan while about 2,200 Americans have been killed in a conflict that ended inconclusively.
Over the past two years, Australia has reduced its military personnel from about 1,500.
Asked at a news conference in Perth whether going into Afghanistan was worth it, Morrison said, "freedom is always worth it".
In a statement he, Defence Minister Peter Dutton and Foreign Minister Marise Payne said, "this decision represents a significant milestone in Australia's military history".
They said more than 39,000 Australian Defence Force personnel had been deployed on Operations SLIPPER and HIGHROAD.
"But safeguarding Afghanistan's security has come at a cost," they said, referring to the 41 deaths and the larger number who were wounded, "some physically and others mentally."
They said a "complex task of making peace" lay ahead.
"Australia continues to support the peace negotiations between the Afghan government and the Taliban. We encourage both parties to commit to the peace process and call on the Taliban to cease the violence."
While Australia's military contribution would reduce, "we will continue to support the stability and development of Afghanistan through our bilateral partnership, and in concert with other nations.
"This includes our diplomatic presence, development cooperation program, and continued people-to-people links, including through our training and scholarship programs.
"Australia remains committed to helping Afghanistan preserve the gains of the last 20 years, particularly for women and girls."
The announcement of the withdrawal comes as fresh controversy engulfs Ben Roberts-Smith, who won a VC in Afghanistan but has been accused of war crimes.
Nine this week alleged he buried material in his backyard, including pictures of soldiers behaving badly in a makeshift bar at the Australian Tarin Kowt base and classified information.
Roberts-Smith has denied the allegations against him.
At his news conference, Morrison dismissed a question about the allegations of Australians committing war crimes, saying, "There will be time to talk about those things. Today is not that time".
Author: Michelle Grattan - Professorial Fellow, University of Canberra