KABUL, Afghanistan — Around the time his hometown turned into the epicenter of coronavirus in Afghanistan and the government began a lockdown, Mohamed Kareem Tawain, an 80-year-old dentist in the western city of Herat, had a dream one night: that he took some money from his wife to distribute for charity, but found no one on the streets to give it to.

“When I came to the clinic the next morning and interpreted my dream, I knew it had a direct connection to the coronavirus,” Mr. Tawain said. “That morning, I decided I would waive the rent for the 10 shops I own,” which comes to about $6,000.

The virus is spreading across Afghanistan at a time when the country is grappling with a raging war with the Taliban, an election dispute that has split the government and brought a $1 billion aid reduction from the United States as punishment, and a dire economy that has plunged about half the population below the poverty line.

In such a moment of need, ordinary Afghans have stepped up to share the little that they have, tapping into a culture of generosity, volunteerism and care within the community that many feared had been eroded by decades of war, survival-first imperatives, greed, and corruption.