KUALA LUMPUR (Reuters) - Malaysia's export growth rose unexpectedly in June, driven by higher demand for manufactured goods from the United States, which offset the hit to the oil-producing country's commodities shipments.

Exports in June grew 3.4 percent from a year earlier, data from the International Trade and Industry Ministry showed on Friday, a stark contrast to economists' estimates of a 4.2 percent decline. In May, exports slid 0.9 percent, hit by the effects of weak global oil prices.

Malaysia's exports to the U.S. jumped 22 percent in June, the highest on-year growth recorded this year, on higher shipments of electrical and electronic products, as well as optical and scientific equipment.

The spike in demand helped offset declining commodity exports. Malaysia, the world's second-largest producer of palm oil, saw a 20.3 percent annual drop in palm oil and palm-based exports in June.

Exports of liquefied natural gas and crude oil also remained weak, down 29.2 percent and 7.3 percent respectively.

Economists said while the trade figures were a positive surprise, sustained growth would be dependant on commodity prices.

"We are in a small downturn right now but the outlook is still for a slight recovery in oil prices towards the end of the year, as global supplies increase," said Julia Goh, an economist for UOB Bank in Malaysia.

Exports to the European Union grew 4.1 percent from a year earlier, but those to China fell 20.3 percent, due to lower exports of commodities and manufactured goods.

The ringgit <MYR=MY> rose 0.4 percent to 4.032 per dollar after the data. The currency was emerging Asia's worst performing last year.

Imports in June expanded 8.3 percent from a year earlier, up from the previous month's 3.1 percent rise.

June's trade surplus widened to 5.5 billion ringgit ($1.36 billion), compared to 3.3 billion ringgit in May.

In the first half of 2016, exports grew 1.2 percent while imports rose 1.4 percent from the same period last year. A trade surplus of 41.8 billion ringgit was recorded, compared with 41.7 billion ringgit in the first half of 2015.

(Reporting by Rozanna Latiff; Editing by Sam Holmes)