The CMS detector, including its muon system, has been operating at the CERN LHC in increasingly challenging conditions for about 15 years. The muon detector was designed to provide excellent triggering and track reconstruction for muons produced in proton–proton collisons at an instantaneous luminosity (L\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$\\mathcal {L}$$\\end{document}) of 1×1034\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$1 \ imes 10^{34}$$\\end{document} cm-2\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$^{-2}$$\\end{document}s-1\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$^{-1}$$\\end{document}. During the Run 2 data-taking period (2015–2018), the LHC achieved an instantaneous luminosity of twice its design value, resulting in larger background rates and making the efficient detection of muons more difficult. While some backgrounds result from natural radioactivity, cosmic rays, and interactions of the circulating protons with residual gas in the beam pipe, the dominant source of background hits in the muon system arises from proton–proton interactions themselves. Charged hadrons leaving the calorimeters produce energy deposits in the muon chambers. In addition, high-energy particles interacting in the hadron calorimeter and forward shielding elements generate thermal neutrons, which leak out of the calorimeter and shielding structures, filling the CMS cavern. We describe the method used to measure the background rates in the various muon subsystems. These rates, in conjunction with simulations, can be used to estimate the expected backgrounds in the High-Luminosity LHC. This machine will run for at least 10 years starting in 2029 reaching an instantaneous luminosity of L=5×1034cm-2s-1\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$\\mathcal {L} = 5 \ imes \ ext {10}^\ ext {34}\\,\ ext {cm}^\ ext {-2}\\,\ ext {s}^\ ext {-1}$$\\end{document} and increasing ultimately to L=7.5×1034cm-2s-1\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$\\mathcal {L} = 7.5 \ imes \ ext {10}^\ ext {34}\\,\ ext {cm}^\ ext {-2}\\,\ ext {s}^\ ext {-1}$$\\end{document}. These background estimates have been a key ingredient for the planning and design of the muon detector upgrade.