A typical problem of gyrotrons operating at high harmonics of the electron cyclotron frequency is the suppression of parasitic near-cutoff waves excited at lower harmonics. In this paper, a method for a significant improvement of the selectivity of the second-harmonic gyrotrons is proposed. This method is based on the use of quasi-regular cavities with short irregularities, which provide different effects on the process of excitation of the operating second-harmonic wave and the spurious fundamental-harmonic wave by the electron beam.