The U.S. trade deficit widened unexpectedly in December to $40.2 billion, fueled by the highest oil prices and oil imports since October 2008, the Commerce Department said on Wednesday.

Wall Street analysts surveyed before the report had expected the trade deficit to narrow to $36 billion from $36.4 billion in November.

The 10.4 percent jump in the trade gap came as both U.S. exports and imports showed healthy gains for the month.

Exports rose 3.3 percent to $142.7 billion, the biggest percentage increase since March 2007.

You saw a huge drop in global trade activity during the recession. I think this is further evidence that we are in a recovery mode, said Scott Brown, chief economist at Raymond James and Associates in St. Petersburg, Florida.

U.S. stocks index futures remained flat after the data, while Treasury debt prices held gains and the dollar extended losses versus the yen.

For the year, the U.S. trade deficit totaled $380.7 billion, down sharply from $695.9 billion in 2008, after a year in which the global financial crisis took a heavy toll on trade.

The politically sensitive U.S. trade deficit with China fell in December to $18.1 billion and totaled $226.8 billion for the year, down from a record $268.0 billion in 2008.

U.S. exports to China in December were a record large $8.4 billion.

The trade gap with China is by far the largest the United States has with any country and symbolizes what many U.S. politicians believe are China's unfair trade practices.

Meanwhile, a separate report showed U.S. mortgage applications dipped last week, reflecting reduced demand for home purchase loans even as rates on 30-year loans fell to their lowest since December.

A continuation of lackluster demand for home purchase loans would not bode well for the U.S. housing market, which remains highly vulnerable to setbacks and heavily reliant on government intervention.

(Reporting by Doug Palmer; Additional reporting by Julie Haviv in New York, Editing by Andrea Ricci)