The U.S. trade deficit shrank unexpectedly in June as American oil production helped to wean the economy off foreign imports.

The trade gap narrowed by 7% to $41.5 billion from May’s $44.7 billion, according to a Commerce Department release. The drop was better than the expansion to $44.8 billion that economists had predicted, according to Bloomberg data.

The drop was driven by fewer foreign imports of such items as autos, cellular phones — and oil.

Imports of petroleum were $27.4 billion, the lowest since November 2010. That helped to drive down the U.S. trade deficit in fuel to $14.7 billion, the smallest since May 2009.

The decline in demand for foreign petroleum products is partly due to the increased production now taking place within U.S. borders. Field production of crude oil and petroleum products in the U.S. has grown 15.2% in the past 12 months from May, the most recent month for which data are available.

US petroleum production

In May, the U.S. is produced 11.2 million barrels a day and nearly 347 million barrels for the month — that’s a almost a quarter more fuel than the total 280 million barrels bought overseas that month.

Increasing domestic petroleum production points to growing U.S. energy independence — an especially important factor as geopolitical tensions escalate in eastern Europe and the Middle East.