We study the reflection of two counter-propagating modes of the light field in a ring resonator by ultracold atoms either in the Mott insulator state or in the superfluid state of an optical lattice. We obtain exact numerical results for a simple two-well model and carry out statistical calculations appropriate for the full lattice case. We find that the dynamics of the reflected light strongly depends on both the lattice spacing and the state of the matter-wave field. Depending on the lattice spacing, the light field is sensitive to various density-density correlation functions of the atoms. The light field and the atoms become strongly entangled if the latter are in a superfluid state, in which case the photon statistics typically exhibit complicated multimodal structures.