To add to yamad's answer (which is pretty good), for about a decade, the way pain was thought to lower the effect of rewards is by tonic release of dopamine; in contrast, pleasure/reward triggers phasic release of dopamine. If you want an (imperfect) electrical analogy, the tonic release is the "DC" level and phasic are transients or spikes on top of that. More correctly:
Tonic dopamine activity refers to the level of
extrasynaptic dopamine that is present at a
steady-state concentration in the extracellular
space. [...]
Importantly, tonic
dopamine levels regulate the responsiveness of
the phasic dopamine system to salient
environmental cues: high tonic dopamine
attenuates phasic dopamine release whereas
low tonic dopamine facilitates phasic dopamine
firing. The level of tonic dopamine in the limbic
striatum is in turn modulated by corticostriatal
and hippocampal afferents and homeostasis
Increased tonic dopamine is known to result from prolonged stress or pain, a
mechanism that might have evolved to ensure rest and low activity levels during injury.
And among the refs cited in support of that is a (pretty highly cited) experiment of Floresco et al. (2003):
we report dissociable regulation of dopamine neuron discharge by
two separate afferent systems in rats; inhibition of pallidal afferents selectively increased the population activity of dopamine
neurons, whereas activation of pedunculopontine inputs increased burst firing. Only the increase in population activity increased
ventral striatal dopamine efflux. After blockade of dopamine reuptake, however, enhanced bursting increased dopamine efflux
three times more than did enhanced population activity. These results provide insight into multiple regulatory systems that
modulate dopamine system function: burst firing induces massive synaptic dopamine release, which is rapidly removed by
reuptake before escaping the synaptic cleft, whereas increased population activity modulates tonic extrasynaptic dopamine
levels that are less influenced by reuptake.
That was the view circa 2008. A 2016 review paints a fairly different picture (citing only post-2009 primary studies for this update):
Recent studies suggest that dopamine neurons in the VTA [ventral tegmental area] and SN [substantia nigra] form a heterogeneous population tuned to either (or both) aversive or rewarding stimuli.
The heterogeneity of dopamine neurons in response to aversive and rewarding stimuli suggests that they serve unique functional roles. Cells activated by reward and inhibited by punishment are well suited to code motivational valence, whereas neurons activated by both rewarding and punishing stimuli are likely to code motivational salience [stimulus awareness]. Neurons coding motivational valence [whether the stimulus is positive or negative in value] would provide a signal for reward seeking, evaluation, and value learning, in line with current theories on the role of dopamine in reward processing. In contrast, neurons coding motivational salience would provide a signal for detection and prediction of highly important events independent of valence, pursuant to dopamine's role in salience processing. These distinct aspects of dopamine neurotransmission might be neuroanatomically separate: dopaminergic neurons coding motivational valence have been found more commonly in the ventromedial SN and lateral VTA with projections to nucleus accumbens [NAc] shell, whereas neurons coding motivational salience are more often reported in the dorsolateral SN with projections to the nucleus accumbens core.

It's anybody's guess if this is the correct/complete picture. Time will tell.
The primary evidence for this updated view seems mostly based (in order of the number of citations) on 3 papers:
One open problem remains though: how are pain and pleasure balanced by the brain? For example, we expect that an organism could tolerate mild pain in order to reap a reward. Where is this balancing decision made? A tentative answer comes from the authors of the aforementioned review, who in a newer (2017) empirical study found that the decision area in this case is the medial orbitofrontal cortex:

Alas this latter study used monetary rewards, so it's not terribly clear how well its result applies to lower species.
And on a really interesting [for me] research side, in some species dopmamine signaling not only alters behavior but induces morphological changes in response to the environment; examples include both predator (e.g. Echinoid larvae) and prey (e.g. Daphnia) changing their morphology in reaction to prey/predators via dompamine-mediated pathways. Although not obviously related to predator/prey behavior, but to the wider environment; dopamine mediates myopia (eye growth) in humans and other species.
Finally, I only focused on the highlighted question at the end of the questotion-body. Your title question is actually substantially broader.
Just with respect to the rewarding side: liking and wanting are thought to have substantially different neurobiological circuitry, cf. the [highly cited] review of Berridge et al. (2009) (whose closely related work Kaj's answer indicated).
A similarly extensive line of work exists with respect to pain (i.e., the aversive side), e.g. see Baliki and Apkarian (2015) "Nociception, Pain, Negative Moods, and Behavior Selection".