Also known as lattice enthalpy.
The lattice energy of an ionic compound is the energy holding its ions together. Since the sum force between ions in a crystal is attractive, its lattice energy should be quoted as a negative value, although this is not always done in practice.
Ionic compounds are principally held together by the electrostatic attraction between the positively and negatively charged ions. The energy U of attraction between any two ions is given by Coulomb's law, and is given by:
U = k × Q1 × Q2 / r
where k is a constant equal to 1/4π ε0 (ε0 is the permittivity of free space), Q1 and Q2 are the charges on the ions, and r is the distance between them. Thus the attraction is proportional to the ionic charges (which are equal to the elementary charge, e, times a whole number), and inversely proportional to the distance between the ions.
However, in a real crystal there are many millions of such ions packed together, each contributing an attractive (i.e. negative) term to each other counterion, and a repulsive (i.e. positive) term to each other like ion. Depending on the relative geometry of the ions (that is, the crystal structure) these positive and negative terms will converge to a particular degree which is described by a factor called the Madelung constant, given the symbol A. Typical values of Madelung constants for common crystal types range between 1.5 and 2.5.
This leads to the first of two important ways to determine the lattice energy of a compound: a calculation based on the theoretical model of a crystal as a pure ionic system. To get from the Coulomb equation for two ions, to an equation applicable to an actual crystal, is fairly complex, and also somewhat speculative as it does not lead to one definitive equation but rather to a range of different approximations.
Among the older and simpler of these is the Born-Landé equation, with the form
U = [k × NA × A × Q1 × Q2 / r] × (1-1/n)
where U is the molar lattice energy, NA is Avogadro's constant, A is the Madelung constant for the crystal, k, r, Q1 and Q2 are as above, and n is a factor known as the Born exponent based on the compressibility of the crystal.
Another equation, again associated with Max Born, is the Born-Mayer equation. This is based on more complicated theory and has the form
U = [k × NA × A × Q1 × Q2 / r] × (1-r*/r)
This is roughly similar to the first equation and indeed both give similar results. That there is more than one equation for calculating the same property is a reminder that these calculations do not give definitive results but are approximations based on theory.
The second major way of determining lattice energies is by experiment. Lattice energies cannot actually be determined directly this way, but can be deduced from the Born-Haber cycle (again thanks to Max Born), a special application of Hess's law which takes into account all the other energies involved in the formation of ionic compounds. These values, such as ionization energy and electron affinity, can be measured and form the basis of an experimental lattice energy.
And because an ionic compound is, in theory, the product of the union of gaseous counterions, the strict definition of the molar lattice energy of a crystal is the energy given out when a mole of gaseous anions and cations come together from an infinite distance to form the crystal. This is indeed the only definition given by some sources, e.g. the Chambers Science and Technology Dictionary (thus forcing me to consult other sources for this writeup). Of course, we can't actually take a mole of sodium ions in the gas phase, separate them an infinite distance from a mole of chloride ions also in the gas phase, bring them together, and measure the energy released. Therefore this third definition is purely theoretical, an abstraction based on the model of a perfect ionic solid, and for actual values we must use either equations as above, e.g. Born-Mayer, or experimental data from Born-Haber cycles.
These two are never in full agreement - theoretical lattice energies as derived from equations are never quite the same as the experimental values. To a large degree this is because real crystals are not perfectly ionic but also show a degree of covalency. As described by Fajans' rules, the covalency (and thus the departure from the theoretical lattice energy) is greatest with large negative ions, small positive ions, and multiple charges on both ions. The degree of agreement between theoretical and experimental lattice energies is thus an indicator of the covalency of a theoretically "ionic" solid.