Recent surveys of the Local Group spiral Galaxies M31 and M33 with XMM-Newton yielded a large number of X-ray sources. As part of the effort to identify and classify the objects responsible for this X-ray emission, we have obtained optical spectra of the brightest optical counterparts of the identified X-ray sources, using the 1.3m Skinakas Telescope. Most of these objects are foreground star candidates. The purpose of the present study is to confirm this identification and to explore the compatibility between the optical spectral classification and the observed X-ray properties of the sources. We have obtained optical spectra for the 14 brightest optical counterparts of X-ray sources identified by XMM-Newton in the direction of M31 and for 21 optical counterparts in the direction of M33, using the 1.3m Skinakas telescope in Crete, Greece. All of the M31 sources and all but one of the M33 sources were confirmed to be foreground stars, of spectral types between A and M. One of the stars is a late M dwarf with H-alpha emission, a flare star, also displaying strong X-ray variability. One of the M~33 sources (lying within the D25 ellipse) corresponds to a previously known background galaxy, LEDA 5899.