The low surface-charge density, poor stability and irreparable surface of triboelectric materials under harsh environments are still some obstacles for developing high-performance triboelectric nanogenerators (TENGs). In particular, a two-dimensional MXene material's surface is likely to be corroded by water molecules under high humidity conditions owing to its hydrophilic nature, limiting the output performance and stability of TENGs. Herein, an approach for fabricating a humidity- and contamination-resistant MXene-based TENG is established using the electrospinning technique. First, nanofibrous layers of MXene/MoS2 composites blended in a cellulosic polymer matrix were prepared, benefitting the high surface roughness and controlled air-trapping pores. Furthermore, the prepared nanofibrous layers were chemically modified with stearic acid (SA), which enhances the hydrophobicity and electronegativity of MXene/MoS2 composites. In a typical synthesis, four different compositions of MXene/MoS2/cellulose acetate nanofibers were prepared, which illustrates that an increasing concentration of MoS2 could effectively tune the surface oxidation, hydrophilic nature, and surface roughness of MXene as well as induce a piezoelectricity-enhanced triboelectric potential. On the other side, the SA modification ultimately generated a superhydrophobic surface with low surface energy and a high water contact angle of ∼154°. The integrated TENG displayed an enhanced output voltage of ∼140 V and an instantaneous power density of ∼2975 mW cm−2 with long-term stability under high humidity conditions. Additionally, the self-cleaning properties were demonstrated, ensuring the sustainability and reusability of the TENG in a contaminated environment. Moreover, the fabricated MXene-based superhydrophobic layer can harvest the energy on dripping water droplets based on the liquid–solid contact-electrification TENG mode. Overall, this work paves the way for the design and development of humidity- and contamination-resistant triboelectric materials and guides the study of harvesting of distributed environmental energy efficiently.