The standard model (SM) production of four top quarks (t t ¯ t t ¯) in proton–proton collisions is studied by the CMS Collaboration. The data sample, collected during the 2016–2018 data taking of the LHC, corresponds to an integrated luminosity of 137fb-1 at a center-of-mass energy of 13TeV. The events are required to contain two same-sign charged leptons (electrons or muons) or at least three leptons, and jets. The observed and expected significances for the t t ¯ t t ¯ signal are respectively 2.6 and 2.7 standard deviations, and the t t ¯ t t ¯ cross section is measured to be 12.6-5.2+5.8fb. The results are used to constrain the Yukawa coupling of the top quark to the Higgs boson, yt, yielding a limit of |yt/ytSM|<1.7 at 95 % confidence level, where ytSM is the SM value of yt. They are also used to constrain the oblique parameter of the Higgs boson in an effective field theory framework, H^ < 0.12. Limits are set on the production of a heavy scalar or pseudoscalar boson in Type-II two-Higgs-doublet and simplified dark matter models, with exclusion limits reaching 350–470GeV and 350–550GeV for scalar and pseudoscalar bosons, respectively. Upper bounds are also set on couplings of the top quark to new light particles.