The departing Afghan President Hamid Karzai has taken one last swipe at the US and warned the incoming administration at home to be watchful of Washington.

In his final address to the nation which has come ahead of Ashraf Ghani's swearing in ceremony, Karzai squarely put the blame on the US and the Afghan neighbour Pakistan for the persisting Taliban insurgency.

"One of the reasons was that the Americans did not want peace because they had their own agenda and objectives," said the outgoing president.

Karzai went on: "Today, I tell you again that the war in Afghanistan is not our war, but imposed on us and we are the victims. No peace will arrive unless the US or Pakistan want it. My advice to the next government is to be very careful with America and the West."

Karzai, then a relatively unknown political figure, was installed in the presidential office following the fall of Taliban rule in 2001 as part of the US-led intervention in Afghanistan in response to the 9/11 attack.

Karzai has often criticised the US over the high number of civilian casualties during the war, and the relations between the two countries became highly fragile during the last few years of his tenure.

Nonetheless, such remarks from him in his final address as president sparked a rare but strong rebuttal from the US ambassador to Afghanistan James Cunningham.

The US diplomat told reporters: "His remarks, which were uncalled for, do a disservice to the American people and dishonour the huge sacrifices Americans have made here... that's the part that is ungracious and ungrateful."

"However I am absolutely confident in reassuring Americans that Afghan themselves absolutely value and are grateful for the sacrifices and commitment of the United States to the future of this country."

The US has spent about $100 billion in aid since 2001 including training the Afghan troops and building infrastructure in the country. However, Karzai did not thank the US while mentioning the names of more than half a dozen countries including South Korea, Germany, India, Japan and China for their cooperation.