The increasing demand for lithium resources in the rapidly growing new energy industry has spurred interest in efficient lithium extraction from salt-lakes using Nanofiltration membranes, owing to their impressive ionic rejection capabilities. However, achieving effective Mg2+/Li+ selective separation remains a critical challenge for the widespread application of NF membranes in lithium extraction. This study focuses on the utilization of poly(dimethyldiallylammonium chloride)-modified polyethersulfone substrate for interfacial polymerization modulation in the preparation of polyamide nanofiltration membrane. The prepared membrane exhibited high MgCl2 rejection. And then the prepared membrane was subsequently optimized by post-modification with piperazine. Previous and subsequent modifications resulted in smaller pores, narrower pore size distribution, and lower surface negativity of the modified membrane. These properties contributed to the significantly higher MgCl2 rejection rate of the modified membrane (94.7%) than that of the Control membrane (46.1%). This excellent rejection property ensured the efficient Mg2+/Li + separation performance of the modified membrane. It was noteworthy that the Mg2+/Li+ separation factor for lithium extraction in simulated brine reached an impressive 77.2. In addition, the modified membrane retained a comparable pure water permeance and Na2SO4 rejection rate as the control membrane and showed excellent stability, significantly improving the Mg2+/Li + separation efficiency while reducing energy consumption. This study presents a simple strategy to fabricate NF membranes with excellent Mg2+/Li+ separation factor.