One of the most distressing symptoms of many neuropathic pain syndromes is the enhanced pain sensation to tactile or thermal stimulation (hyperalgesia). In the present study we used functional magnetic resonance imaging (fMRI) and explored brain activation patterns during acute impact pain and mechanical hyperalgesia in the human ultraviolet (UV)-B model. To investigate pharmacological modulation, we examined potential differential fMRI correlates of analgesic and antihyperalgesic effects of two intravenous cyclooxygenase inhibitors, i.e. parecoxib and acetylsalicylic acid (ASA). Fourteen healthy volunteers participated in this double-blinded, randomized and placebo-controlled crossover study. Tactile stimuli and mechanical impact hyperalgesia were tested at the site of a UV-B irradiation and acute mechanical pain was tested at a site distant from the irradiated skin. These measurements were conducted before and 30 min after a 5-min intravenous infusion of either saline (placebo), parecoxib 40 mg or ASA 1000 mg. Acute mechanical pain and mechanical hyperalgesia led to widespread activations of brain areas known to comprise the human pain matrix. Analgesic effects were found in primary (S1) and secondary (S2) somatosensory cortices, parietal association cortex (PA), insula, anterior parts of the cingulate cortex and prefrontal cortices. These brain areas were also modulated under antihyperalgesic conditions. However, we observed a greater drug-induced modulation of mainly PA and inferior frontal cortex during mechanical hyperalgesia; during acute mechanical pain there was a greater modulation of mainly bilateral S2. Therefore, the results of the present study suggest that there is a difference in the brain areas modulated by analgesia and antihyperalgesia.