MicroRNAs (miRNAs) play vital roles in plant development and defence responses against various stresses. Here, we show that blocking miR1871 improves rice resistance against Magnaporthe oryzae and enhances grain yield simultaneously. The transgenic lines overexpressing miR1871 (OX1871) exhibit compromised resistance, suppressed defence responses and reduced panicle number resulting in slightly decreased yield. In contrast, the transgenic lines blocking miR1871 (MIM1871) show improved resistance, enhanced defence responses and significantly increased panicle number leading to enhanced yield per plant. The RNA-seq assay and defence response assays reveal that blocking miR1871 resulted in the enhancement of PAMP-triggered immunity (PTI). Intriguingly, miR1871 suppresses the expression of LOC_Os06g22850, which encodes a microfibrillar-associated protein (MFAP1) locating nearby the cell wall and positively regulating PTI responses. The mutants of MFAP1 resemble the phenotype of OX1871. Conversely, the transgenic lines overexpressing MFAP1 (OXMFAP1) or overexpressing both MFAP1 and miR1871 (OXMFAP1/OX1871) resemble the resistance of MIM1871. The time-course experiment data reveal that the expression of miR1871 and MFAP1 in rice leaves, panicles and basal internode is dynamic during the whole growth period to manipulate the resistance and yield traits. Our results suggest that miR1871 regulates rice yield and immunity via MFAP1, and the miR8171-MFAP1 module could be used in rice breeding to improve both immunity and yield.