JALALABAD, Afghanistan — No one here knows the man whose left leg is shackled to the wall of cell No. 5. Last week, he finished tearing his mattress to shreds and then moved onto his clothes, ripping his shirt and pants off before falling asleep naked.

The man’s brothers drove him here from southern Kandahar province two weeks ago, drawn by the same belief that has attracted families from across Afghanistan for more than two centuries. Legend has it that those with mental disorders will be healed after spending 40 days in one of the shrine’s 16 tiny concrete cells.