We report results on an elastic cross section measurement in proton-proton collisions at a center-of-mass energy 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≤−t≤0.67 GeV2. 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 dσ/dt agrees well with the results obtained at 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 σelfid=462.1±0.9(stat.)±1.1(syst.)±11.6(scale)~μb.