WASHINGTON (Reuters) - U.S. housing starts unexpectedly rose in July as building activity increased across the board, supporting the view that investment in residential construction will rebound after slumping in the second quarter.

New developments are seen under construction along the RiverWalk, adjoining downtown Milwaukee, Wisconsin, U.S. August 15, 2016. REUTERS/Aaron P. Bernstein

Groundbreaking increased 2.1 percent to a seasonally adjusted annual pace of 1.2 million units, the highest level since February, the Commerce Department said on Tuesday. June’s starts were largely unchanged at a 1.19 million-unit rate.

Permits for future construction dipped 0.1 percent to a 1.15 million-unit rate last month. Economists polled by Reuters had forecast housing starts slipping to a 1.18 million-unit pace last month and building permits rising to a 1.16 million-unit rate.

Investment in residential construction contracted in the second quarter for the first time in more than two years.

That, together with an outright decline in inventory investment, a continued downturn in business spending and weak government outlays, held gross domestic product to a 1.2 percent annualized growth rate during the quarter.

Against the backdrop of a tightening labor market, which is steadily driving up wages, economists expect a rebound in residential construction spending in the third quarter. But with housing starts still running ahead of permits, the anticipated bounce-back could be modest.

A survey of homebuilders published on Monday showed confidence rising in August, with builders optimistic about sales now and over the next six months. However, their views about prospective buyer traffic softened a bit.

Groundbreaking on single-family homes, the largest segment of the market, rose 0.5 percent to a 770,000-unit pace in July, also the highest level since February. Single-family starts rose in the South and West, but tumbled 23.9 percent in the Northeast and fell 2.6 percent in the Midwest.

Housing starts for the volatile multi-family segment increased 5.0 percent to a 441,000-unit pace. Groundbreaking on multi-family housing projects with five units or more jumped to the highest level since September 2015.

The multi-family segment of the market continues to be supported by strong demand for rental accommodation as some Americans shun homeownership in the aftermath of the housing market collapse.

Permits for the construction of single-family homes fell 3.7 percent last month to a 711,000-unit rate, the lowest level since September 2015, while multi-family building permits rose 6.3 percent to a 441,000-unit pace.