We report a moisture-driven power generator (MPG) based on a MXene layered membrane confining hygroscopic ionic liquids. This unique configuration harnesses ambient humidity, simultaneously achieving efficient moisture absorption and selective ion transport, thereby directly generating electricity. This work not only unveils the microstructure-performance relationship enhanced by the ionic engineering but also provides an efficient design route for high-performance MPG.