A search is presented for long-lived charged particles that decay within the CMS detector and produce the signature of a disappearing track. A disappearing track is an isolated track with missing hits in the outer layers of the silicon tracker, little or no energy in associated calorimeter deposits, and no associated hits in the muon detectors. This search uses data collected with the CMS detector in 2015 and 2016 from proton-proton collisions at a center-of-mass energy of 13 TeV at the LHC, corresponding to an integrated luminosity of 38.4 fb−1. The results of the search are interpreted in the context of the anomaly-mediated supersymmetry breaking model. The data are consistent with the background-only hypothesis. Limits are set on the product of the cross section for direct production of charginos and their branching fraction to a neutralino and a pion, as a function of the chargino mass and lifetime. At 95% confidence level, charginos with masses below 715 (695) GeV are excluded for a lifetime of 3 (7) ns, as are charginos with lifetimes from 0.5 to 60 ns for a mass of 505 GeV. These are the most stringent limits using a disappearing track signature on this signal model for chargino lifetimes above ≈0.7 ns.[Figure not available: see fulltext.].