Lightweight, low-cost supercapacitors with the capability of rapidly storing a large amount of electrical energy can contribute to meeting continuous energy demands and effectively levelling the cyclic nature of renewable energy sources. The excellent electrochemical performance of supercapacitors is due to a reversible ion adsorption in porous carbon electrodes. Recently, it was demonstrated that ions from the electrolyte could enter sub nanometre pores, greatly increasing the capacitance. However, the molecular mechanism of this enhancement remains poorly understood. Here we provide the first quantitative picture of the structure of an ionic liquid adsorbed inside realistically modelled microporous carbon electrodes. We show how the separation of the positive and negative ions occurs inside the porous disordered carbons, yielding much higher capacitance values (125 F g(-1)) than with simpler electrode geometries. The proposed mechanism opens the door for the design of materials with improved energy storage capabilities. It also sheds new light on situations where ion adsorption in porous structures or membranes plays a role.