  Let $f$ be a primitive Hilbert modular form of parallel weight $2$ and level
$N$ for the totally real field $F$, and let $p$ be a rational prime coprime to
$2N$. If $f$ is ordinary at $p$ and $E$ is a CM extension of $F$ of relative
discriminant $\Delta$ prime to $Np$, we give an explicit construction of the
$p$-adic Rankin-Selberg $L$-function $L_{p}(f_E,\cdot)$. When the sign of its
functional equation is $-1$, we show, under the assumption that all primes
$\wp\vert p$ are principal ideals of ${\mathcal O}_{F}$ which split in
${\mathcal O}_{E}$, that its central derivative is given by the $p$-adic height
of a Heegner point on the abelian variety $A$ associated with $f$.
  This $p$-adic Gross--Zagier formula generalises the result obtained by
Perrin-Riou when $F={\mathbf Q}$ and $(N,E)$ satisfies the so-called Heegner
condition. We deduce applications to both the $p$-adic and the classical Birch
and Swinnerton-Dyer conjectures for~$A$.
