Observations with the Short Wavelength Spectrometer (SWS) onboard the Infrared Space Observatory (ISO) are used to determine the D/H ratio in Jupiter's and Saturn's atmospheres. The D/H ratio is measured independently in hydrogen (i.e. from the HD/H2 ratio) and methane (from CH3D/CH4). Observations of the HD R(2) and R(3) rotational lines at 37.7 and 28.5 mu m, of the H2 S(0) and S(1) quadrupolar lines at 17.1 and 28.2 mu m, of the methane nu4 band at 7.7 mu m, and of the CH3D nu6 band at 8.6 mu m are analyzed jointly, allowing a retrieval of thermal profiles and molecular abundances. On each planet, the D/H determinations from H2 and CH4 give consistent results, but the accuracy is not sufficient to precisely determine the enrichment factor of D/H in methane. Combining these determinations, we obtain the following values for the D/H ratio in hydrogen: (D/H)H_2= (2.25+/- 0.35) 10-5 in Jupiter and (1.70+0.75-0.45) 10-5 on Saturn. These values are consistent with and somewhat more accurate than most earlier values. Comparing with inferences of protosolar D/H from solar wind measurements, it is confirmed that Jupiter is a reliable indicator of the protosolar D/H ratio. The protosolar deuterium abundance inferred from the jovian value, (2.1 +/- 0.4) 10-5, indicates a minor decrease of the D/H ratio, over the last 4.55 Gyr, in the part of the Galaxy where the Solar System was formed. Although the error bars overlap, most measurements, including ours, may point to a slightly smaller D/H ratio in Saturn's atmosphere than in Jupiter's, a surprising result which needs confirmation.