Since the ions are charged, they cannot pass through cellular membranes via simple diffusion. Two different mechanisms can transport the ions across the membrane: active or passive transport.
An example of active transport of ions is the Na-K-ATPase (NKA). NKA is powered by the hydrolysis of ATP into ADP and an inorganic phosphate; for every molecule of ATP hydrolized, three Na are transported outside and two K are transported inside the cell. This makes the inside of the cell more negative than the outside and more specifically generates a membrane potential V of about .
An example of passive transport is ion fluxes through Na, K, Ca, and Cl channels. Unlike active transport, passive transport is powered by the arithmetic sum of osmosis (a concentration gradient) and an electric field (the transmembrane potential).  Formally, the molar Gibbs free energy change associated with successful transport is  where  represents the gas constant,  represents absolute temperature,  is the charge per ion, and  represents the Faraday constant.
In the example of Na, both terms tend to support transport: the negative electric potential inside the cell attracts the positive ion and since Na is concentrated outside the cell, osmosis supports diffusion through the Na channel into the cell.  In the case of K, the effect of osmosis is reversed: although external ions are attracted by the negative intracellular potential, entropy seeks to diffuse the ions already concentrated inside the cell.  The converse phenomenon (osmosis supports transport, electric potential opposes it) can be achieved for Na in cells with abnormal transmembrane potentials: at , the Na influx halts; at higher potentials, it becomes an efflux.