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β and Ca ii 8542 Å lines and make a detailed comparison with radiative hydrodynamic simulations. Observations of the X8.2 class solar flare SOL 2017-09-10T16:06 UT obtained with the Swedish Solar Telescope reveal bright horizontal emission layers in Hβ line-wing images located near the footpoints of the flare loops. The apparent separation between the ribbon observed in the Hβ wing and the nominal photospheric limb is about 300–500 km. The Ca ii 8542 Å 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, toward 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β ribbons and their significant elevation above the photosphere. The ribbons in the Ca ii 8542 Å 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β line-wing intensities can be a useful tracer of flare energy deposition in the lower solar atmosphere.