We present ISO-SWS observations of H2 pure-rotational line emission from the disks around low and intermediate mass pre-main-sequence stars as well as from young stars thought to be surrounded by debris disks. We detect `warm (T ~ 100-200 K) H2 gas around many sources, including tentatively the debris-disk objects. The mass of this warm gas ranges from ~1E-4 Solar mass up to 8E-3 Solar mass, and can constitute a non-negligible fraction of the total disk mass. Complementary single-dish 12CO 3-2, 13CO 3-2 and 12CO 6-5 observations have been obtained as well. These transitions probe cooler gas at T ~ 20-80 K. Most objects show a double-peaked CO emission profile characteristic of a disk in Keplerian rotation, consistent with interferometer data on the lower-J lines. The ratios of the 12CO 3-2/ 13CO 3-2 integrated fluxes indicate that 12CO 3-2 is optically thick but that 13CO 3-2 is optically thin or at most moderately thick. The 13CO 3-2 lines have been used to estimate the cold gas mass. If a H2/CO conversion factor of 1E4 is adopted, the derived cold gas masses are factors of 10-200 lower than those deduced from 1.3 millimeter dust emission assuming a gas/dust ratio of 100,in accordance with previous studies. The warm gas is typically 1-10 % of the total mass deduced from millimeter continuum emission, but can increase up to 100% or more for the debris-disk objects. Thus, residual molecular gas may persist into the debris-disk phase. No significant evolution in the H2, CO or dust masses is found for stars with ages in the range of 1E6-1E7 years, although a decrease is found for the older debris-disk star beta Pictoris. Existing models fail to explain the amount of warm gas quantitatively.