EX Hya is one of the few double-lined eclipsing cataclysmic variables that allow an accurate measurement of the binary masses. We analyze orbital phase-resolved UVES/ VLT high resolution spectroscopic observations of EX Hya with the aims of deriving the binary masses and obtaining a tomographic image of the illuminated secondary star. We present a novel method for determining the binary parameters by directly fitting an emission model of the illuminated secondary star to the phase-resolved line profiles of NaI lambda 8183/ 8195 in absorption and emission and CaII lambda 8498 in emission. The fit to the NaI and CaII line profiles, combined with the published K1, yields a white-dwarf mass M1 = 0.790 +/- 0.026 Msun, a secondary mass M2 = 0.108 +/- 0.008 Msun, and a velocity amplitude of the secondary star K2 = 432.4 +/- 4.8 km s-1. The secondary is of spectral type dM5.5 +/- 0.5 and has an absolute K-band magnitude of MK = 8.8. Its Roche radius places it on or very close to the main sequence of low-mass stars. It differs from a main sequence star by its illuminated hemisphere that faces the white dwarf. The secondary star contributes only 5% to the observed spin-phase averaged flux at 7500 A, 7.5% at 8200 A, and 37% in the K-band. We present images of the secondary star in the light of the NaI doublet and the CaII emission line derived with a simplified version of Roche tomography. We have discovered narrow spectral lines from the secondary star in EX Hya that delineate its orbital motion and allow us to derive accurate masses of both components. The primary mass significantly exceeds recently published values. The secondary is a low-mass main sequence star that displays a rich emission line spectrum on its illuminated side, but lacks chromospheric emission on its dark side.