The X-ray background from 0.1 to 7 keV has been studied using data of high spectral and spatial resolution from the ASCA Solid-state Imaging Spectrometers and ROSAT Position Sensitive Proportional Counter. Analysing both the diffuse background radiation and resolved sources, we have carried out a series of joint spectral fits of the ASCA and ROSAT data. As found previously with ASCA data alone, the spectrum of the X-ray background can be fitted well by a single power law from 1 to 7 keV; to account for the Galactic emission below 1 keV, a model with a power law plus two thermal components fits well to the measurements of ASCA and ROSAT from 0.1 to 7 keV. Overall, the photon index of the power-law model ranges from 1.4 to 1.5, and no obvious excess is found between 1 and 3 keV as predicted from some previous observations. Below 1 keV, the models become more complicated and involve a mixture of extragalactic and Galactic sources. As some of the extragalactic contributions should be from point sources, we have examined the ASCA and ROSAT spectra of resolved sources individually: a stellar source having a well-fitted thermal spectrum and two AGN having a much steeper power-law spectrum (with a photon index of about 3); the accumulated spectrum of other nonstellar sources resolved by ROSAT is also steeper than the average AGN spectrum. Fitting the X-ray background spectrum observed by ASCA and the accumulated point source spectrum by ROSAT together by varying the contribution from steep-spectrum sources, such as quasars, to the background, we find that the steep-spectrum sources contribute less than 30 per cent in the 0.5-2 keV band and drop to below 10 per cent over 2-10 keV. This fraction is provided by sources brighter than a few times 10(-15) erg cm(-2) s(-1) (in the 0.5-2 keV band). Constrained by our spectral fitting results, the major contributor of the X-ray background must be a single population with similar flat spectra.