Ionic bonding occurs as a result of valence electron imbalances. The valence shell of an atom is most stable with 8 electrons. This is called the octet rule. The quintessential example of ionic bonding is sodium chloride (NaCl), also known as table salt.

Sodium only has one electron in its valence (level 3s) shell. It can be made to satisfy the octet rule by removing one electron or adding seven. The former is much simpler. Chlorine has 5 electrons in its 3p shell and 2 in its 3s shell, for a total of 7. It can become stable by losing all of the level 3 electrons or gaining 1 level 3 electron. The latter is simpler.

Both of these atoms are normally electrically neutral with the above-described conditions. Moving electrons around will change the charges of the atoms, but this is where things get interesting. Sodium requires 5.2eV (electron volts) to free its 3s electron, and addition of an electron to chlorine to form chloride releases 3.7eV. This gives a net of 1.5eV input for the process. This means that for sodium and chlorine to form sodium chloride, 1.5eV per atomic pair must be expended. This is not favored! The material should destabilize easily, but this is not the case. Something else is afoot. That something is electrostatic interaction.

Briefly, the change in charge of the two atoms causes them to be attracted to each other electrostatically. The energy released as the two approach each other is about 6eV. This balances out the above deficit and yields a net release of 4.5eV. The formation of sodium chloride is now favored, making it a stable material. Note that the atoms will sit at the lowest-potential balance between the repulsive forces of their electron clouds on each other and their overall attractive forces. This can be diagrammed as a potential well. Unlike covalent bonds, ionic bonds are non-directional. Ionic materials tend to be good insulators and are brittle.

It should be noted that this example only deals with two atoms, and in an actual ionic solid forces would be spread about a bit more. This only gives a general idea of the process.

Adapted from my Materials Science and Engineering class notes.