Tony Dejak, Associated Press
In this Wednesday, Feb. 18, 2015, photo, carpenter Joe Tominc cuts wood for a post on a new construction home in Pepper Pike, Ohio. The Commerce Department issues its last of three estimates of how the U.S. economy performed in the January-March quarter on Wednesday, June 24, 2015.

WASHINGTON — The U.S. economy contracted in the first three months of the year, just not as much as previously estimated. More recent data show that the weakness was largely temporary, with a rebound in the works for the April-June quarter.

The economy, as measured by the gross domestic product, shrank at a seasonally adjusted annual rate of 0.2 percent from January through March, the Commerce Department said Wednesday. That's better than last month's estimate of a 0.7 percent decrease.

Harsh winter weather slowed spending by keeping consumers away from shopping malls and auto dealerships. The trade deficit ballooned, slicing growth by the most since 1985 as exports fell and imports rose.

Yet consumers stepped up their spending in May, and home sales are climbing — signs that the economy is back on track.

In addition, many of the headwinds the economy faced in the first quarter are fading.

Exports were hammered by a sharp rise in the dollar's value, which makes U.S. goods more expensive overseas. The dollar has increased 15 percent in the past year compared with a basket of overseas currencies.

That also makes imports cheaper and better able to compete with U.S.-made goods. Imports increased 7.1 percent in the first quarter, while exports fell 5.9 percent. That widened the trade gap, cutting nearly 1.9 percentage points from growth, the most in 30 years.

A trade dispute at West Coast ports also contributed to the disparity, but it has since been resolved. And the dollar's value has leveled off since March, suggesting its impact will lessen.

Oil and gas companies, meanwhile, sharply cut back on drilling and exploration activity and spent much less on steel pipe and other equipment. Those cutbacks occurred in the wake of last year's steep drop in oil prices, but have since slowed and should stop lowering growth in the second half of the year, analysts forecast.

Americans saved more in the first quarter, aided by lower gas prices and greater hiring. Consumer spending growth slipped to just 2.1 percent, down from 4.4 percent in the final three months of last year.

But since then there have been signs that Americans are spending more freely. That should provide a crucial boost to growth in the second quarter and the rest of the year. Consumer spending accounts for 70 percent of economic activity.

Sales at retail stores and restaurants jumped 1.2 percent in May, as shoppers spent more on clothes, building materials and furniture.

Consumers are also willing to spend more on major purchases, potentially a sign of growing confidence in what has been a stop-and-start expansion. Auto sales jumped in May to the highest level in nearly a decade.