By Paul Kiernan

WASHINGTON -- Trade between the U.S. and the rest of the world picked up in June, with both exports and imports rising as the global economy began climbing out of the recession caused by the coronavirus pandemic.

The deficit narrowed 7.5% from May to $50.7 billion, the Commerce Department said in a report Wednesday. Exports rose 9.4% to $158.3 billion in June, while imports rose 4.7% to $208.9 billion.

Economists surveyed by The Wall Street Journal had forecast a trade gap of $50.3 billion.

Fueling the rise in exports was a 14% jump in outbound shipments of goods, which had cratered in April and May as much of the global economy was shut down to contain the spread of Covid-19. Exports of services rose much more slowly at 1%.

U.S. consumer demand picked up in June as parts of the economy reopened. Unemployment fell, and retail sales picked up as consumers bought more cars, clothing and electronics.

The automotive industry saw both imports and exports more than double in June from May as lockdowns eased and showrooms reopened.

"The industry has been holding up and recovering well," General Motors Chief Financial Officer Dhivya Suryadevara told reporters last week.

Write to Paul Kiernan at paul.kiernan@wsj.com