The small martian satellites Phobos and Deimos orbit in synchronous rotation with inclinations of only 0.01° and 0.92°, respectively, relative to the planet's equatorial plane. Thus, an observer at near-equatorial latitudes on Mars could occasionally observe solar eclipses by these satellites (see ref. 1, for example). Because the apparent angular diameter of the satellites is much smaller than that of the Sun, however, such events are more appropriately referred to as transits. Transit data can be used for correcting and refining the orbital ephemerides of the moons. For example, Phobos is known to exhibit a secular acceleration that is caused by tidal dissipation within Mars. Long-term, accurate measurements are needed to refine the magnitude and origin of this dissipation within the martian interior as well as to refine the predicted orbital evolution of both satellites. Here we present observations of six transits of Phobos and Deimos across the solar disk from cameras on Mars aboard the Mars Exploration Rovers Spirit and Opportunity. These are the first direct imaging observations of satellites transiting the Sun from the surface of another planet.