A data sample of events from proton-proton collisions with at least two jets, and two isolated same-sign or three or more charged leptons, is studied in a search for signatures of new physics phenomena. The data correspond to an integrated luminosity of 137fb-1 at a center-of-mass energy of 13TeV, collected in 2016–2018 by the CMS experiment at the LHC. The search is performed using a total of 168 signal regions defined using several kinematic variables. The properties of the events are found to be consistent with the expectations from standard model processes. Exclusion limits at 95% confidence level are set on cross sections for the pair production of gluinos or squarks for various decay scenarios in the context of supersymmetric models conserving or violating R parity. The observed lower mass limits are as large as 2.1TeV for gluinos and 0.9TeV for top and bottom squarks. To facilitate reinterpretations, model-independent limits are provided in a set of simplified signal regions.