© 2021 CERN for the benefit of the CMS collaboration.The muon trigger system of the CMS experiment uses a combination of hardware and software to identify events containing a muon. During Run 2 (covering 2015-2018) the LHC achieved instantaneous luminosities as high as 2 × 10 cm s while delivering proton-proton collisions at √s = 13 TeV. The challenge for the trigger system of the CMS experiment is to reduce the registered event rate from about 40 MHz to about 1 kHz. Significant improvements important for the success of the CMS physics program have been made to the muon trigger system via improved muon reconstruction and identification algorithms since the end of Run 1 and throughout the Run 2 data-taking period. The new algorithms maintain the acceptance of the muon triggers at the same or even lower rate throughout the data-taking period despite the increasing number of additional proton-proton interactions in each LHC bunch crossing. In this paper, the algorithms used in 2015 and 2016 and their improvements throughout 2017 and 2018 are described. Measurements of the CMS muon trigger performance for this data-taking period are presented, including efficiencies, transverse momentum resolution, trigger rates, and the purity of the selected muon sample. This paper focuses on the single- and double-muon triggers with the lowest sustainable transverse momentum thresholds used by CMS. The efficiency is measured in a transverse momentum range from 8 to several hundred GeV.