  In this paper, we establish the modularity of every elliptic curve $E/F$,
where $F$ runs over infinitely many imaginary quadratic fields, including
$\mathbb{Q}(\sqrt{-d})$ for $d=1,2,3,5$. More precisely, let $F$ be imaginary
quadratic and assume that the modular curve $X_0(15)$, which is an elliptic
curve of rank $0$ over $\mathbb{Q}$, also has rank $0$ over $F$. Then we prove
that all elliptic curves over $F$ are modular. More generally, when
$F/\mathbb{Q}$ is an imaginary CM field that does not contain a primitive fifth
root of unity, we prove the modularity of elliptic curves $E/F$ under a
technical assumption on the image of the representation of
$\mathrm{Gal}(\overline{F}/F)$ on $E[3]$ or $E[5]$.
  The key new technical ingredient we use is a local-global compatibility
theorem for the $p$-adic Galois representations associated to torsion in the
cohomology of the relevant locally symmetric spaces. We establish this result
in the crystalline case, under some technical assumptions, but allowing
arbitrary dimension, arbitrarily large regular Hodge--Tate weights, and
allowing $p$ to be small and highly ramified in the imaginary CM field $F$.
