Flare ribbons are bright manifestations of flare energy dissipation in the lower solar atmosphere. For the first time, we report on high-resolution imaging spectroscopy observations of flare ribbons situated off-limb in the H$beta$ and Ca II 8542 {AA} lines and make a detailed comparison with radiative hydrodynamic simulations. Observations of the X8.2-class solar flare SOL2017-09-10T16:06 UT obtained with the Swedish Solar Telescope reveal bright horizontal emission layers in H$beta$ line wing images located near the footpoints of the flare loops. The apparent separation between the ribbon observed in the H$beta$ wing and the nominal photospheric limb is about 300 - 500 km. The Ca II 8542 {AA} line wing images show much fainter ribbon emissions located right on the edge of the limb, without clear separation from the limb. RADYN models are used to investigate synthetic spectral line profiles for the flaring atmosphere, and good agreement is found with the observations. The simulations show that, towards the limb, where the line of sight is substantially oblique with respect to the vertical direction, the flaring atmosphere model reproduces the high contrast of the off-limb H$beta$ ribbons and their significant elevation above the photosphere. The ribbons in the Ca II 8542 {AA} line wing images are located deeper in the lower solar atmosphere with a lower contrast. A comparison of the height deposition of electron beam energy and the intensity contribution function shows that the H$beta$ line wing intensities can be an useful tracer of flare energy deposition in the lower solar atmosphere