The first observation of the tt¯H process in a single Higgs boson decay channel with the full reconstruction of the final state (H→γγ) is presented, with a significance of 6.6 standard deviations (σ). The CP structure of Higgs boson couplings to fermions is measured, resulting in an exclusion of the pure CP-odd structure of the top Yukawa coupling at 3.2σ. The measurements are based on a sample of proton-proton collisions at a center-of-mass energy s=13 TeV collected by the CMS detector at the LHC, corresponding to an integrated luminosity of 137 fb-1. The cross section times branching fraction of the tt¯H process is measured to be σtt¯HBγγ=1.56-0.32+0.34 fb, which is compatible with the standard model prediction of 1.13-0.11+0.08 fb. The fractional contribution of the CP-odd component is measured to be fCPHtt=0.00±0.33.