The U.S. economy contracted at a slower-than-expected pace in the second quarter as the slump in business and residential investment moderated sharply, according to government data on Friday that backed views the recession was winding down.

Gross domestic product, which measures total goods and services output within U.S. borders, fell at a 1.0 percent annual rate, the Commerce Department said, after tumbling 6.4 percent in the January-March quarter, the biggest decline since a matching fall in the first quarter of 1982. It was previously reported as a 5.5 percent drop.

With the contraction in the second quarter, U.S. GDP has fallen for four straight quarters for the first time since government records started in 1947.

Analysts polled by Reuters had forecast GDP falling at a 1.5 percent rate in the second quarter.

The advance report showed business investment decreased at an 8.9 percent rate in the second quarter after diving 39.2 percent in the previous quarter. Investment in nonresidential structures fell at an 8.9 percent rate compared to a 43.6 percent drop in the first quarter.

Residential investment, which is at the core of the longest recession since the Great Depression, dropped at a 29.3 percent rate in the April-June period after plummeting by 38.2 percent in the first quarter.

Business inventories continued to be a drag on overall GDP, declining by a record $141.1 billion in the second quarter as firms aggressively cut back on new production to reduce stockpiles of unsold goods. Inventories fell by $113.9 billion in the first quarter. The drop in inventories shaved 0.83 percentage points from second-quarter GDP. Excluding inventories, GDP fell 0.2 percent in the second quarter compared to a 4.1 percent decline in the first quarter, the department said.

Consumer spending, which accounts for over two-thirds of U.S. economic activity, fell at a 1.2 percent rate in the second quarter after rising 0.6 percent in the previous quarter. The freefall in exports braked sharply in the second quarter. Exports fell at a 7.0 percent rate after plunging 29.9 percent in the first quarter. There were positive contributions from the federal, state and local government during the second quarter.

Annual benchmark revisions issued by the department showed the economy barely grew in 2008, expanding at an annual rate of 0.4 percent, the smallest since 1991, instead of the 1.1 percent previously estimated.

(Reporting by Lucia Mutikani; Editing by Andrea Ricci)