It is permissible to perform pilgrimage (Hajj or Umrah), prayer, or circumambulation (Tawaf) on behalf of a deceased person, and they benefit from it—even if the deceased was under divine displeasure, they may be forgiven or have their hardship relieved through such actions. The deceased is made aware of these acts. Even performing these acts for an adversary (nāṣib) could lessen their burden. Acts of piety, connection, and Hajj can be performed for both the living and the dead, but prayer on behalf of a living person is not permitted.
Commentary #2