Ionisation energy is the energy required to remove one electron from an isolated gaseous atom (in its ground state). This generates a cation (ion with a positive charge).
Both Mg and Al are in period three, but Al has 13 electrons compared to Mg which has 12.
Al has the electronic structure 1s2 2s2 2p6 3s2 3p1. The extra electron is place in the 3p orbital and is further away from the nuclues therefore it is easier to remove.