Pain is a negative affective state arising from tissue damage or inflammation. Because pain is aversive and its relief is innately rewarding, animals may learn to avoid a context in which pain is experienced and prefer one where pain relief occurs. It is generally accepted that vertebrate animals experience pain; however, there is currently inconclusive evidence that the affective component of pain occurs in any invertebrate. Here, we show that octopuses, the most neurologically complex invertebrates, exhibit cognitive and spontaneous behaviors indicative of affective pain experience. In conditioned place preference assays, octopuses avoided contexts in which pain was experienced, preferred a location in which they experienced relief from pain, and showed no conditioned preference in the absence of pain. Injection site grooming occurred in all animals receiving acetic acid injections, but this was abolished by local anesthesia. Thus, octopuses are likely to experience the affective component of pain.