  We report results on an elastic cross section measurement in proton-proton
collisions at a center-of-mass energy $\sqrt{s}=510$ GeV, obtained with the
Roman Pot setup of the STAR experiment at the Relativistic Heavy Ion Collider
(RHIC). The elastic differential cross section is measured in the four-momentum
transfer squared range $0.23 \leq -t \leq 0.67$ GeV$^2$. We find that a
constant slope $B$ does not fit the data in the aforementioned $t$ range, and
we obtain a much better fit using a second-order polynomial for $B(t)$. The $t$
dependence of $B$ is determined using six subintervals of $t$ in the STAR
measured $t$ range, and is in good agreement with the phenomenological models.
The measured elastic differential cross section $\mathrm{d}\sigma/\mathrm{dt}$
agrees well with the results obtained at $\sqrt{s} = 546$ GeV for
proton--antiproton collisions by the UA4 experiment. We also determine that the
integrated elastic cross section within the STAR $t$-range is
$\sigma^\mathrm{fid}_\mathrm{el} = 462.1 \pm 0.9 (\mathrm{stat.}) \pm 1.1
(\mathrm {syst.}) \pm 11.6 (\mathrm {scale})$~$\mu\mathrm{b}$.
