Mature microRNAs (miRNAs) are small-sized RNAs cleaved from precursor microRNAs (pre-miRNAs) by the RNase Dicer. Various miRNAs play key regulatory roles in tumorigenesis and metastasis, and are therefore potential diagnostic and prognostic cancer biomarkers. However, detecting miRNAs and pre-miRNAs accurately and selectively in living cells remains a major challenge, as the mature miRNA sequence is also present in its pre-miRNA and current sequence probes exhibit poor gene delivery efficiency. Herein, we report a strategy for selectively and accurately detecting miRNA-21 and pre-miRNA-21 in living cells using functional MoS2 nanosheets (NSs) loaded with rationally engineered molecular beacons (MBs). The exfoliated MoS2 nanosheets (NSs) with a mean lateral diameter of 50-70nm were functionalized with the aptamer AS1411 and polyethylene glycol (MoS2-PEG-AS) to achieve target-cell-specific delivery and to enhance biocompatibility. The large available surface of the MoS2-PEG-AS was loaded with MB probes. The resulting MoS2-PEG-AS/MBs present cancer-cell-targeting ability, good protection properties, good optical stability, and biocompatibility. We demonstrated that the resulting nanoprobes can selectively image miRNA-21 and pre-miRNA-21 in various cell lines by facilitating enhanced fluorescence in the presence of miRNA-21 and pre-miRNA-21. Thus, these MoS2-PEG-AS/MBs are potentially a tool to discriminate between intracellular miRNA and pre-miRNA at different expression levels. Graphical abstract.