The presence of industrial pollutants, especially salts, heavy metals ions, and dyes in water and wastewater is considered a serious environmental issue. To eliminate these pollutants, a high‐performing nanofiltration (NF) membrane was prepared by blending the functionalized mesoporous carbon CMK‐5 (F‐CMK‐5) nanofiller. This membrane was synthesized by introducing the active groups of sulfonyl and amide to the surface of mesoporous carbon CMK‐5 through covalent functionalization. Characterizations were conducted to study the membranes' physical properties and separation performance in terms of antifouling properties and rejection of salts, heavy metal ions, and dyes. The interactions between the active sites of the nanocomposite membrane and the studied solutes, including dyes and heavy metal ions in aqueous solutions, were studied by the density functional based tight binding method and structural optimization was carried out. Insertion of the F‐CMK‐5 nanofiller was eventuated in a remarkable increase in surface hydrophilicity, pure water flux, and antifouling properties. For all membranes, the lowest and the highest salt rejection was obtained for NaCl and Na2SO4, respectively, exhibiting the characteristics of NF membranes. Moreover, M0.3 with 0.3 wt% nanofiller showed the highest rejection for heavy metal ions (Fe2+ = 99.9%, Zn2+ = 99.9%, Cu2+ = 99.7%, and Pb2+ = 99.2%) and dyes (RB5 = 99.21, DR16 = 98.87, and MB = 98.12%), as well as high separation performance for filtration of multipollutant solutions. The reusability and 144 h uninterrupted filtration experiments for M0.3 confirmed the stability of the membrane. The findings suggest that the PES/F‐CMK‐5 nanocomposite NF membrane is a promising candidate for water and wastewater treatment.