According to Hubble's law, light and other kinds of electromagnetic radiation emitted from distant objects are redshifted. The more distant the source, the more intense is the redshift. Now, the expansion of the universe is expected to explain the redshift and its nearly linear dependence on distance between source and observer. But isn't there an other source influencing the redshift? We know that a light beam passing the Sun is deflected by the Sun's gravity in accordance with predictions made by Einstein's general theory of relativity. This deflection is dependant on a gravitational interaction between the Sun and the light beam. Thus, the position of the Sun is affected by the light beam, though by such a tiny amount that it is impossible to detect the disturbance of the Sun's position. Now, during its journey to the Earth a light beam, originating from a distant source in the Universe, is passing a certain amount of elementary particles and atoms. If the light beam interacts gravitationally with those elementary particles and atoms, affecting the microscopic mechanical properties of the individual elementary particles and atoms at issue, can this interaction be detected as a redshift of the light beam? If so, could we use this gravity redshift to measure the mean density of matter and energy in space? The beginning of the sentence "If the light beam interacts gravitationally with those elementary particles and atoms..." should be interpreted to say "If the light beam interacts gravitationally with those elementary particles and atoms by way of leaving them in a state of acceleration different from their initial state of acceleration...." This clarification seems to necessitate the additional question: "why would a gravitationally interacting object (a cluster of photons) passing another gravitationally interacting object (a mass) leave that mass in the same state as before the passage?"
This is similar to the "tired light" hypothesis, and isn't consistent with current cosmological data. The best argument against tired light is that if the redshift was caused by an interaction between light and matter, there would be a frequency dependence of this interaction, as light interacts with matter differently when it is at different frequencies. Astronomical sources, however, don't exhibit any frequency-dependent dispersion in their spectra--they look like they're just redshifted back, as you would expect if they were receding.
If the light beam interacts gravitationally with those elementary particles and atoms, affecting the microscopic mechanical properties of the individual elementary particles and atoms at issue, can this interaction be detected as a redshift of the light beam?
Consider light passing a particle. The light comes from a large distance and leaves to a large distance. From gravity it will very slightly blueshift on approach and redshift when leaving the particle, which is both far too little to measure and the total effect from gravity on the frequency is essentially zero. Gravity can deflect the light and this is how galaxies cause gravitational lensing. So this cannot be detected as redshift.
If so, could we use this gravity redshift to measure the mean density of matter and energy in space?
No. But the deflection can be used to measure intervening mass. Google for the "bullet cluster" to show an example.
As Chris Kuklewicz points out, a photon passing a particle, or a larger clump of matter, is blueshifted as it falls in and equally redshifted as it comes out, so there's no overall "tired-light-like" redshift due to an effect of this sort. On the other hand, for certain choices of coordinates, you actually can regard the observed cosmological redshift as partially or even entirely a gravitational redshift.
In Newtonian language, if you imagine the source of the light at the center of a spherically symmetric expanding spacetime, then the light travels "uphill" in a gravitational potential all the way to the observer. The observed redshift is partially due to this redshift and partially due to the observer's motion. Conversely, if you put the observer at the center, the light "falls downhill" all the way to the observer. This gives a different breakdown of the observed redshift into gravitational and Doppler contributions. Of course, the world is relativistic, not Newtonian, but you can think of these two pictures as representations of the general relativistic point of view in two different coordinate systems. The original reference for this stuff is a paper by Bondi, Monthly Notices of the RAS, 107, 410-425 (1947), and it's essentially the point of view taken by Peacock in this set of notes.
This just drives home the fact that whether the observed redshift is gravitational or not depends on your choice of coordinates. There is no "fact of the matter." There are so many confusing statements about this in textbooks that David Hogg and I wrote a paper arguing for our own point of view, that the most natural way to think about the cosmological redshift is as a pure Doppler shift -- not a gravitational redshift and certainly not a whole different animal caused by "the stretching of space." (The textbook by Harrison, despite many good qualities, is an egregious offender in this regard.) Even if you don't agree with our conclusion, this paper may be useful in putting the issue in context.