Changes in the climate system's energy budget are predominantly revealed in ocean temperatures and the associated thermal expansion contribution to sea-level rise. Climate models, however, do not reproduce the large decadal variability in globally averaged ocean heat content inferred from the sparse observational database, even when volcanic and other variable climate forcings are included. The sum of the observed contributions has also not adequately explained the overall multi-decadal rise. Here we report improved estimates of near-global ocean heat content and thermal expansion for the upper 300 m and 700 m of the ocean for 1950-2003, using statistical techniques that allow for sparse data coverage and applying recent corrections to reduce systematic biases in the most common ocean temperature observations. Our ocean warming and thermal expansion trends for 1961-2003 are about 50 per cent larger than earlier estimates but about 40 per cent smaller for 1993-2003, which is consistent with the recognition that previously estimated rates for the 1990s had a positive bias as a result of instrumental errors. On average, the decadal variability of the climate models with volcanic forcing now agrees approximately with the observations, but the modelled multi-decadal trends are smaller than observed. We add our observational estimate of upper-ocean thermal expansion to other contributions to sea-level rise and find that the sum of contributions from 1961 to 2003 is about 1.5 +/- 0.4 mm yr(-1), in good agreement with our updated estimate of near-global mean sea-level rise (using techniques established in earlier studies) of 1.6 +/- 0.2 mm yr(-1).