Outgoing Afghan president Hamid Karzai has taken one last swipe at the US, saying that America did not want peace in Afghanistan.
Mr Karzai said that peace will come to Afghanistan if the United States and Pakistan really want it.
The only president Afghanistan has known since the 2001 US-led invasion said the US wanted war in Afghanistan "because of its own interests".
Mr Karzai's relationship with America has grown increasingly fragile in recent years.
The speech was billed as Mr Karzai's last as president. Next week, president-elect Ashraf Ghani Ahmadzai will be sworn in.
Mr Karzai has refused to sign a security agreement with the US that would allow about 10,000 American military advisers and trainers to stay in the country next year. Mr Ghani Ahmadzai has said he will sign it.
The United States has spent more than 100 billion dollars (£61 billion) on aid in Afghanistan since 2001 to train and equip the country's security forces, to pave crumbling dirt roads, to upgrade hospitals and to build schools.
Mr Karzai thanked several countries for their help - India, Japan, China, Iran, Turkey, Saudi Arabia, South Korea and Germany - without mentioning the US.
The speech pointed to the US and the military leaders of neighbouring Pakistan as the powers backing perpetual war.
"If America and Pakistan really want it, peace will come to Afghanistan," Mr Karzai said.
"War in Afghanistan is based on the aims of foreigners. The war in Afghanistan is to the benefit of foreigners. But Afghans on both sides are the sacrificial lambs and victims of this war."
More than 2,200 US forces personnel have died in Afghanistan operations since 2001. Nearly 20,000 have been wounded.
The United Nations says that some 8,000 Afghan civilians have been killed in the conflict over the last five years alone. Mr Karzai has for years railed against US military strikes for the civilian casualties that they cause - although the United Nations has said insurgents are to blame for the overwhelming majority of casualties.
Mr Karzai's relationship with US president Barack Obama is seen as weak, though American Secretary of State John Kerry appears to have a rapport with the outgoing Afghan president.
Dozens of telephone calls made by Mr Kerry to the two top presidential candidates helped bring about a political deal signed on Sunday for a unity government.
Mr Ghani Ahmadzai was announced by the election commission as winner of a June run-off election plagued by electoral fraud. His opponent, Abdullah Abdullah, will fill the newly created role of government chief executive.
US military and intelligence operatives helped transport Mr Karzai around the region in late 2001, shortly after the attacks in New York and Washington. That US connection helped pave the way to the presidency.
Mr Ghani Ahmadzai's entrance is more conventional. A former finance minister, the new president has worked at the World Bank and earned a PhD from New York's Colombia University.
His path to the presidency follows a long election season that ended with the election commission giving him 55% of the run-off vote.
The 13-year war against the Taliban has largely been turned over to Afghan security forces, a development that has seen casualties among Afghan soldiers rise significantly this year.