A magnetic spectrometer has been developed for the AWAKE experiment at CERN in order to measure the energy distribution of bunches of electrons accelerated in wakefields generated by proton bunches in plasma. AWAKE is a proof-of-principle experiment for proton-driven plasma wakefield acceleration, using proton bunches from the SPS. Electron bunches are accelerated to $mathcal{O}$(1 GeV) in a rubidium plasma cell and then separated from the proton bunches via a dipole magnet. The dipole magnet also induces an energy-dependent spatial horizontal spread on the electron bunch which then impacts on a scintillator screen. The scintillation photons emitted are transported via three highly-reflective mirrors to an intensified CCD camera, housed in a dark room, which passes the images to the CERN controls system for storage and further analysis. Given the known magnetic field and determination of the efficiencies of the system, the spatial spread of the scintillation photons can be converted to an electron energy distribution. A lamp attached on a rail in front of the scintillator is used to calibrate the optical system, with calibration of the scintillator screens response to electrons carried out at the CLEAR facility at CERN. In this article, the design of the AWAKE spectrometer is presented, along with the calibrations carried out and expected performance such that the energy distribution of accelerated electrons can be measured.