The U.S. trade gap narrowed unexpectedly to $26 billion in May to the lowest reading since November 1999 as exports rose despite weak global demand and imports shrank, government data on Friday showed.

The stronger than anticipated export performance could bolster the contribution of trade to economic growth in the second quarter, which is forecast to contract at a slower pace than in the previous three months as the country's recession abates.

A separate report from the Labor Department showed that import prices jumped 3.2 percent last month while export prices were up 1.1 percent.

The Commerce Department said May exports increased 1.6 percent to $123.3 billion, while imports declined by 0.6 percent to $149.3 billion.

Analysts polled by Reuters had expected the trade deficit to widen to $30.2 billion in May. The trade gap in April was revised to $28.8 billion from a previously reported $29.2 billion deficit.

May's import level was the lowest since July 2004 and the 10th straight monthly decline, providing further evidence of weak demand in the recession-mired United States.

The trade deficit report is another indicator that things are not improving as expected, said William Larkin, portfolio manager with Cabot Money Management in Boston. There is growing pessimism about how quickly the U.S. will recover, which I think will be slower than people expect.

The auto sector has been hard hit in the economic slowdown and May imports of automotive vehicles and parts slipped to $10.2 billion, the lowest level since March 1996, while auto exports were the lowest since July 1998.

The monthly deficit on goods trade with China grew to $17.5 billion from $16.8 billion in April and was the largest with any single country.

But the U.S. trade deficit with other big trading partners declined, falling to $2.8 billion with the European Union in May, for the lowest reading since March 1999, and retreating to $1.9 billion with Japan, which was the lowest since February 1984.

Imported oil cost $51.21 a barrel in May, up from $46.60 in April. The value of crude oil imports in May declined only slightly to $13.4 billion, despite a sharper decline in the quantity of oil actually imported, to 262 million barrels from 293 million in April, the Commerce Department said.

The increase in oil prices was a factoring driving import prices higher in June, Labor Department data showed.

Economists polled by Reuters had expected a 2 percent increase in import prices, after a 1.4 percent rise in May, initially reported as a 1.3 percent gain.

The increase for June was the largest since a matching 3.2 percent jump in November 2007. The last time the index recorded a bigger gain was in September 1990, when it rose 3.4 percent.

Import prices have risen for four consecutive months, but are still down for the year ended in June, largely because of volatile oil prices.

The Labor Department said petroleum prices rose 20.3 percent in June, the largest monthly advance since April 1999. However, these prices are still down 45.9 percent over the past 12 months.

(Additional reporting by Emily Kaiser and John Parry; Editing by Neil Stempleman)

(Reporting by Alister Bull, Editing by Neil Stempleman)