The government on Wednesday also updated its estimates of growth leading into this year. They show the economy expanded in the second half of 2013 at the fastest pace in a decade and more than previously estimated. The revised data also show that the economy grew faster in 2013 than previously estimated, though more slowly in 2011 and 2012 than earlier thought.
The second quarter's 4 percent growth in the gross domestic product the economy's total output of goods and services was the best showing since a 4.5 percent increase in July-September quarter of 2013.
At the same time, a higher trade deficit slowed growth as imports outpaced a solid increase in exports.
Paul Ashworth, chief U.S. economist at Capital Economics, said that given the solid rebound last quarter, he's boosting his estimate for growth this year to a 2 percent annual rate, up from a previous 1.7 percent forecast. Ashworth said the rebound also supported his view that the Federal Reserve, which is ending a two-day meeting Wednesday, will be inclined to start raising interest rates early next year.
Most economists have been predicting that the Fed would wait until mid-2015 to start raising rates.
"At the margin, this GDP report supports our view that an improving economy will persuade the Fed to begin raising rates in March next year," Ashcroft wrote in a research note.
Ashcroft is among a group of economists who think growing strength in the job market and the overall economy will prod the Fed to move faster to raise rates to make sure inflation doesn't get out of hand.
Stock prices turned generally negative Wednesday in the wake of the GDP report because some investors saw a greater likelihood that the Fed would raise rates sooner than expected.
"We're at the point where we're not sure if good news is good news or bad news," said Jim Paulsen, chief investment strategist at Wells Capital Management.
The GDP report showed that one measure of inflation rose 2 percent last quarter, up from a 1.3 percent rise in the first quarter. The Fed's inflation target is 2 percent, and for two years the GDP measure of inflation has been running below that level. Low inflation has given the Fed leeway to focus on boosting growth to fight high unemployment.
The economy's sudden contraction in the first quarter of this year had resulted from several factors. A severe winter disrupted activity across many industries and kept consumers away from shopping malls and auto dealerships. Consumer spending slowed to an annual growth rate of just 1.2 percent, the weakest showing in nearly three years.
Last quarter, consumer spending, powered by pent-up demand, accelerated to a growth rate of 2.5 percent. That was double the pace of the first quarter.
Spending on durable goods such as autos surged at a 14 percent annual rate, the biggest quarterly gain since 2009. Analysts said that was an encouraging sign of consumers' growing willingness to increase purchases of big-ticket items like cars.
Consumer spending is closely watched because it accounts for more than two-thirds of economic activity.
In the April-June quarter, business investment in new equipment jumped at a 7 percent rate after having fallen 1 percent in the first quarter. That setback had reflected the expiration of business tax breaks at the end of 2013. Those tax breaks led companies to boost equipment spending at the end of last year.
Housing, which had been falling for two straight quarters, rebounded in the spring, growing at a 7.5 percent annual rate.
Government spending also recovered after two consecutive declines.