Context : Cosmic rays ( CRs ) can be studied through the galaxy-wide gamma-ray emission that they generate when propagating in the interstellar medium . The comparison of the diffuse signals from different systems may inform us about the key parameters in CR acceleration and transport . Aims : We aim to determine and compare the properties of the cosmic-ray-induced gamma-ray emission of several Local Group galaxies . Methods : We use 2 years of nearly continuous sky-survey observations obtained with the Large Area Telescope aboard the Fermi Gamma-ray Space Telescope to search for gamma-ray emission from M31 and M33 . We compare the results with those for the Large Magellanic Cloud , the Small Magellanic Cloud , the Milky Way , and the starburst galaxies M82 and NGC253 . Results : We detect a gamma-ray signal at 5 \sigma significance in the energy range 200 MeV – 20 GeV that is consistent with originating from M31 . The integral photon flux above 100 MeV amounts to ( 9.1 \pm 1.9 _ { stat } \pm 1.0 _ { sys } ) \times 10 ^ { -9 } ph cm ^ { -2 } s ^ { -1 } . We find no evidence for emission from M33 and derive an upper limit on the photon flux > 100 MeV of 5.1 \times 10 ^ { -9 } ph cm ^ { -2 } s ^ { -1 } ( 2 \sigma ) . Comparing these results to the properties of other Local Group galaxies , we find indications of a correlation between star formation rate and gamma-ray luminosity that also holds for the starburst galaxies . Conclusions : The gamma-ray luminosity of M31 is about half that of the Milky Way , which implies that the ratio between the average CR densities in M31 and the Milky Way amounts to \xi = 0.35 \pm 0.25 . The observed correlation between gamma-ray luminosity and star formation rate suggests that the flux of M33 is not far below the current upper limit from the LAT observations .