Two ways Pedro.
In the first, with salty seawater on one side of a thin membrane and fresh water on the other, the fresh water naturally migrates though the membrane to the salty side, building up the pressure there. That pressurised water can then drive a turbine and connected dynamo to generate electricity.
In the second way, certain of the atom ions in the fresh water and certain of the atom ions in the salty water are attracted through the membrane to the other side. Since it's negative chloride ions going to the fresh water and positive sodium ions going to the sea water, we end up with all the positive one side and all the negative the other, so we have a battery full of charge from which we can draw electricity.
P.S. Crossed with Bob's post extolling the virtues of Chelsea.
.