Prices of U.S. single-family homes gained more than expected in June and rose in the second quarter, reflecting the lingering boost from homebuyer tax credits that ended in April, Standard & Poor's/Case Shiller home price indexes showed on Tuesday.

The S&P/Case Shiller composite index of 20 metropolitan areas rose 0.3 percent in June from May on a seasonally adjusted basis. The rise was better than the 0.2 percent increase expected by economists polled by Reuters, though slower than the 0.5 percent rise in May.

Unadjusted, the 20-city index gained 1 percent following May's 1.3 percent jump.

S&P, which publishes the indexes, also said home prices nationally rose 4.4 percent in the second quarter after a 2.8 percent drop in the first quarter.

Prices rose in 17 of the 20 metro areas in June, S&P said, adding that in the first half of the year 15 of the 20 areas had positive annual growth rates. The housing market is in better shape than a year ago, S&P said.

The worry starts when you remember that the Homebuyers' Tax Credit has expired, foreclosures are still at high levels, and July data on home sales and starts were very, very weak, David M. Blitzer, chairman of the index committee at S&P, said in a statement.

The inventory of unsold homes and months' supply data were particularly troubling, he said, adding that if this relative weakness in demand continues, it will likely filter through to home prices in coming months.

(Reporting by Lynn Adler, Editing by Chizu Nomiyama)