Scott Morrison has confirmed Australia will withdraw its last remaining troops from Afghanistan by September, in line with the United States and other allies.
The prime minister said the number of Australian Defence Force personnel in Afghanistan had been drawn down from a height of more than 1500 to just 80 troops.
The remaining soldiers will slowly depart within months, drawing the 20-year military mission to a close.
Mr Morrison choked back tears as he read the names of 41 ADF troops killed while serving in Afghanistan.
"These brave Australians are amongst our greatest ever, who have served in the name of freedom," he told reporters in Perth on Thursday.
"We thank them for their service humbly and gratefully."
Australia has had 39,000 troops rotate through Afghanistan during the conflict.
The prime minister was asked whether it was worth going into Afghanistan, given the cost to Australian lives.
"Freedom is always worth it," he said.
Mr Morrison declined to comment on alleged war crimes committed by Australian troops in Afghanistan, or whether the ADF could have done better.
"There will be time to talk about those things. Today is not that time," he said.
He acknowledged the conflict had exacted an enormous toll on the people of Afghanistan, and the complex task of making peace still 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," he said.
The prime minister said while Australia's military contribution would reduce, the country would continue to support the stability of Afghanistan through diplomacy, development programs and people-to-people links.
"Australia remains committed to helping Afghanistan preserve the gains of the last 20 years, particularly for women and girls," he said.
Neil James, from the Australia Defence Association, said there was no point in Australia staying in Afghanistan without the US leading the mission.
"All wars end when one side gives up," he told AAP.
"In some cases both sides get tired and give up. The Afghanistan war was sort of in-between."
He said while the withdrawal of international forces would cause some to doubt why Australia took part, "that is the wrong question".
"A better question is what would have happened if we had not participated?" he said.
"At the end of the day the problems of Afghanistan have always only been able to be solved by Afghans, and the withdrawal of foreign assistance should concentrate minds accordingly, including tackling corruption, fanaticism, ideology and sheer stubborness in not co-operating with each other."
He said the Diggers did not die or get wounded in vain.
"Anyone who claims that has not studied history, morality or strategy, or indeed shown courtesy for the families of the dead and wounded," he said.
Labor defence spokesman Brendan O'Connor acknowledged and thanked past and serving ADF members.
"As Minister for Home Affairs I saw first hand the important role the Australian Defence Force played in building civilian capability when I visited Tarin Kowt in 2010 to be briefed on the AFP training of Afghan national police," he said.
"Labor expects the Australian government to continue to support Afghanistan's peace process and development."
Australian Associated Press