This paper presents a search for direct electroweak gaugino or gluino pair production with a chargino nearly mass-degenerate with a stable neutralino. It is based on an integrated luminosity of 36.1 fb−1 of pp collisions at s=13 TeV collected by the ATLAS experiment at the LHC. The final state of interest is a disappearing track accompanied by at least one jet with high transverse momentum from initial-state radiation or by four jets from the gluino decay chain. The use of short track segments reconstructed from the innermost tracking layers significantly improves the sensitivity to short chargino lifetimes. The results are found to be consistent with Standard Model predictions. Exclusion limits are set at 95% confidence level on the mass of charginos and gluinos for different chargino lifetimes. For a pure wino with a lifetime of about 0.2 ns, chargino masses up to 460 GeV are excluded. For the strong production channel, gluino masses up to 1.65 TeV are excluded assuming a chargino mass of 460 GeV and lifetime of 0.2 ns.[Figure not available: see fulltext.].