On-chip optical gas sensors, which use resonant shifts of cavities to detect molecular concentrations, have the advantages of high sensitivity, real-time detection, and compact footprint. However, such sensors are usually limited by a serious cross-sensitivity issue induced by environmental temperature variations. To overcome this limitation, we study a dual-mode graphene-on-microring resonator to accurately measure gas concentrations without suffering from temperature variations. To be specific, the influences of gas-induced graphene’s optical conductivity changes and environmental temperature variations on effective refractive indices of TE0 and TE1 modes in the resonator can be decoupled based on the modal linear independent responses. With this method, we designed a nitrogen dioxide sensor with a sensitivity of 0.02 nm/ppm and a limit of detection of 0.5 ppm. Our study paves the way for developing on-chip optical gas sensors with excellent sensitivity and temperature stability.