Optical fiber refractive index (RI) sensor with temperature (T) compensation has important application values in biomedicine and environmental monitoring. In order to solve the problem that the liquid RI is affected by T in practical application, which leads to a decrease in detection accuracy. In this paper, a T-compensated RI sensor based on cascaded Mach-Zehnder interference (MZI) and Intermodal interference (IMI) was proposed. Experimental results showed the proposed sensor achieved a sensitivity of 797.41 nm/RIU for the measurement of RI in the range of 1.3333–1.3640, and a sensitivity of 0.120 nm/°C for the measurement of T in the range of 0–60 °C. The resolution (R) of RI and T measurements reached 2.5 × 10−5 RIU and 0.167 °C, respectively. The detection limits (DL) of RI and T measurements are 3.135 × 10−8 RIU and 1.392 °C, respectively. A matrix was obtained to demodulate the cross-sensitivity in RI and T measurements. The proposed sensor shows the advantages of simple structure, low hysteresis, and good stability.