Amitriptyline works by inhibiting the reuptake of neurotransmitters such as serotonin and norepinephrine in the brain, thereby increasing their levels and activity. This mechanism not only helps in alleviating depression but also plays a role in pain relief. The drug also has an effect on various ion channels and receptors, which may contribute to its analgesic properties.