  The $d$-wave superconductor $\mathrm{CeCoIn_5}$ has been proposed as a strong
candidate for supporting the Fulde-Ferrell-Larkin-Ovchinnikov (FFLO) state near
the low-temperature boundary of its upper critical field. Neutron diffraction,
however, finds spin-density-wave (SDW) order in this part of the phase diagram
for field in the $a$-$b$ plane, and evidence for the SDW disappears as the
applied field is rotated toward the tetragonal $c$ axis. It is important to
understand the interplay between the SDW and a possible FFLO state in
$\mathrm{CeCoIn_5}$, as the mere existence of an SDW does not necessary exclude
an FFLO state. Here, based on a model constructed on the basis of available
experiments, we show that an FFLO state competes with an SDW phase. The SDW
state in $\mathrm{CeCoIn_5}$ is stabilized when the field is directed close to
the $a$-$b$ plane. When the field is rotated toward the $c$ axis, the FFLO
state emerges, and the SDW phase disappears. In the FFLO state, the nodal
planes with extra quasiparticles (where the superconducting order parameter is
zero) are perpendicular to the field, and in the SDW phase, the quasiparticle
density of states is reduced. We test this model prediction by measuring heat
transported by normal quasiparticles in the superconducting state. As a
function of field, we observe a reduction of thermal conductivity for field
close to the $a$-$b$ plane and an enhancement of thermal conductivity when
field is close to the $c$ axis, consistent with theoretical expectations. Our
modeling and experiments, therefore, indicate the existence of the FFLO state
when field is parallel to the $c$ axis.
