A measurement of the Higgs boson Yukawa coupling to the top quark is presented using proton-proton collision data at s=13 TeV, corresponding to an integrated luminosity of 137 fb-1, recorded with the CMS detector. The coupling strength with respect to the standard model value, Yt, is determined from kinematic distributions in tt¯ final states containing ee, μμ, or eμ pairs. Variations of the Yukawa coupling strength lead to modified distributions for tt¯ production. In particular, the distributions of the mass of the tt¯ system and the rapidity difference of the top quark and antiquark are sensitive to the value of Yt. The measurement yields a best fit value of Yt=1.16-0.35+0.24, bounding Yt<1.54 at a 95% confidence level.