"From a humanitarian perspective, it would be shocking to require her to travel to her home country," a migration court in the city of Gothenburg said, overruling the Swedish Migration Agency's rejection of her asylum request in May.
The judges noted Bibihal Uzbeki's advanced age, declining health and her "especially vulnerable situation".
The Migration Agency, which does not comment on individual cases, told daily Svenska Dagbladet that "in general, advanced age is not a reason to be granted protection".
In its country assessment report available on its website, the agency says that while the "situation in Afghanistan remains serious", the conflict "has not reached such a level that every Afghan can obtain a residency permit".
The case of Uzbeki and her family has made headlines in Sweden, with the general public calling for Sweden to show kindness to the elderly woman – whose travels through Europe to reach the Scandinavian country were well-documented by the international media.
Wednesday's decision grants Uzbeki temporary residency for 13 months, after which she can apply for an extension.
Her family members in Sweden have also appealed their asylum rejections.
Sweden long pushed for Europe to keep its borders open to fleeing migrants but ended up closing its own borders after receiving 81,000 asylum applications in 2014 and 163,000 in 2015, a number that then plunged to around 30,000 in 2016.