An American historian who spent decades in Afghanistan working to preserve the heritage of the war-torn country has died following a long illness.

An Afghan government statement said on Sunday that Nancy Hatch Dupree, who first came to Afghanistan in 1962 and spent much of her life collecting and documenting historical artefacts, died in Kabul overnight at the age of 90.

She amassed a vast collection of books, maps, photographs and even rare recordings of folk music, all now housed at Kabul University, and wrote five guidebooks.

Many Afghans viewed Dupree as one of their own, and hundreds of people posted condolences on social media.

Nancy Dupree's extraordinary (and selfless) dedication to Afghanistan will not be forgotten. She passed away in her beloved kabul. RIP — Saad Mohseni (@saadmohseni) September 10, 2017

Born in 1927 in India to American parents, Dupree first came to Afghanistan as the wife of diplomat Louis Dupree, a renowned archaeologist and scholar of Afghan culture and history.

After the Soviet invasion of Afghanistan in 1979, Dupree was forced to leave the country, but instead, she moved to a refugee camp in Peshawar in Pakistan to help Afghan refugees.

During her time in Peshawar, Dupree preserved government and non-government documents relating to Afghanistan's history and culture during the Soviet invasion when many priceless books were sold to be used for fuel.

When the Taliban was overthrown in 2001, Dupree chose to stay in Peshawar as she was concerned about the safety of the document collection.

Dupree moved back to Kabul in 2003 and worked with the Afghan government to establish a home for the collection of documents that at the time numbered over 7,000 items.

Very saddened by the death of #NancyDupree. Afghans value and respect her services of decades for #Afghanistan. Nancy will be missed! RIP pic.twitter.com/QdCuujQKDa — Dr. Abdullah (@afgexecutive) September 10, 2017

The collection was eventually moved to Kabul University where today it is now known as the Afghan Collection.

She also established the Louis and Nancy Hatch Dupree Foundation, which promotes the history and culture of Afghanistan. The foundation also ensures the safety of the document collection.