Detection mechanisms for low mass bosonic dark matter candidates, such as the axion or hidden photon, leverage potential interactions with electromagnetic fields, whereby the dark matter (of unknown mass) on rare occasion converts into a single photon. Current dark matter searches operating at microwave frequencies use a resonant cavity to coherently accumulate the field sourced by the dark matter and a near standard quantum limited (SQL) linear amplifier to read out the cavity signal. To further increase sensitivity to the dark matter signal, sub-SQL detection techniques are required. Here we report the development of a novel microwave photon counting technique and a new exclusion limit on hidden photon dark matter. We operate a superconducting qubit to make repeated quantum nondemolition measurements of cavity photons and apply a hidden Markov model analysis to reduce the noise to 15.7 dB below the quantum limit, with overall detector performance limited by a residual background of real photons. With the present device, we perform a hidden photon search and constrain the kinetic mixing angle to ε≤1.68×10^{-15} in a band around 6.011 GHz (24.86 μeV) with an integration time of 8.33 s. This demonstrated noise reduction technique enables future dark matter searches to be sped up by a factor of 1,300. By coupling a qubit to an arbitrary quantum sensor, more general sub-SQL metrology is possible with the techniques presented in this Letter.