The Fermi Large Area Telescope (LAT) has opened the way for comparative studies of cosmic rays (CRs) and high-energy objects in the Milky Way (MW) and in other, external, star-forming galaxies. Using 2 yr of observations with the Fermi LAT, Local Group galaxy M31 was detected as a marginally extended gamma-ray source, while only an upper limit has been derived for the other nearby galaxy M33. We revisited the gamma-ray emission in the direction of M31 and M33 using more than 7 yr of LAT Pass 8 data in the energy range -0.1 100 GeV, presenting detailed morphological and spectral analyses. M33 remains undetected, and we computed an upper limit of´---2.0 10 erg cm s 12 2 1 on the -0.1 100 GeV energy flux (95% confidence level). This revised upper limit remains consistent with the observed correlation between gamma-ray luminosity and star formation rate tracers and implies an average CR density in M33 that is at most half of that of the MW. M31 is detected with a significance of nearly s 10 . Its spectrum is consistent with a power law with photon index G = + 2.4 0.1 stat syst and a -0.1 100 GeV energy flux of ( ) + ---5.6 0.6 10 erg cm s stat syst 12 21 . M31 is detected to be extended with a s 4 significance. The spatial distribution of the emission is consistent with a uniform-brightness disk with a radius of 0°. 4 and no offset from the center of the galaxy, but nonuniform intensity distributions cannot be excluded. The flux from M31 appears confined to the inner regions of the galaxy and does not fill the disk of the galaxy or extend far from it. The gamma-ray signal is not correlated with regions rich in gas or star formation activity, which suggests that the emission is not interstellar in origin, unless the energetic particles radiating in gamma rays do not originate in recent star formation. Alternative and nonexclusive interpretations are that the emission results from a population of millisecond pulsars dispersed in the bulge and disk of M31 by disrupted globular clusters or from the decay or annihilation of dark matter particles, similar to what has been proposed to account for the so-called Galactic center excess found in Fermi-LAT observations of the MW.