Specifically, the toxic chemicals are furocoumarins, which are found in some weeds and also a range of plants used in food. Those include celery, carrot, parsley, fennel, parsnip, lime, bitter orange, lemon, grapefruit, and sweet orange. Furocoumarins include chemicals with linear structures, psoralens, and angular structures, called angelicins, though not all of them are toxic.
Furocoumarins can enter skin cells, and for those that are phototoxic, become activated by exposure to ultraviolet light. The light causes the chemicals to form cross-linking bonds with the pyrimidine bases in DNA. This ties the double-stranded genetic material together, halting replication, which in turn leads to cell death and inflammation.
Though it's likely not top-of-mind for most cooks, the phenomenon has been noted for centuries. For instance, in ancient Egypt, people who experienced loss of skin pigment (vitiligo) would treat the condition by covering their skin with the juice of false bishop's weed (Ammi majus) and then lying in the sun to darken their skin. The weed contains two psoralen derivates that can darken skin upon exposure to UV light. But, it's a risky treatment as too much psoralens and/or too much light can easily cause a harsh case of phytophotodermatitis.
Once the painful reaction occurs, treatment includes drugs that can ease the inflammation. The man in the NEJM case was treated with a topical steroid cream and lotion. Still, it took months for a full recovery. Of course, now that he knows, if he gets a lime burn again, there's no one else to blameāit's his own fault.