pH is a measure of the divergence of a solution from chemical neutrality, i.e. where water is self-hydrolyzing in equilibrium. This means every new hydromium ion (H3O+) is balanced with a new hydroxide ion (OH-), resulting from the self-hydrolysis of two water molecules (2H2O). Note that in both cases, the overall (net) charge is 0. Neutrality is defined as pH 7.0, where pH greater than 7.0 indicates basic consitions, while a pH below 7.0 indicates acidic conditions.
Divergence from neutrality is enacted by adding an acid or a base to water. Once the acidic or basic species has been added, reactions will ensue between water molecules and the acid/base molecules, which will result in a shift away from pH 7.0. The magnitude of this shift is proportional to the strength of the acid/base being added. Whereas bases will "strip" protons from the water molecules (forming OH- ions), acids will attach protons to the water molecules (forming H3O+ ions).
pH is often physically measured by utilizing electrodes that detect variances in the permeability of positively charged ions (e.g.K+ or Na+) across a semi-permeable glass barrier. This effect depends on the number of H3O+ species present in the solution, and is reliant upon the creation of an electrochemical gradient across the glass barrier.