We show that the equations of motion of generalized theories of gravity are equivalent to the thermodynamic relation δQ=TδS. Our proof relies on extending previous arguments by using a more general definition of the Noether charge entropy. We have thus completed the implementation of Jacobson's proposal to express Einstein's equations as a thermodynamic equation of state. Additionally, we find that the Noether charge entropy obeys the second law of thermodynamics if the energy-momentum tensor obeys the null energy condition. Our results support the idea that gravitation on a macroscopic scale is a manifestation of the thermodynamics of the vacuum.