The United States' foreign trade deficit narrowed last month to its lowest level in more than four years, despite a visible rebound in oil imports, the government reported yesterday.

Commerce Department figures showed imports exceeded exports by $1.06 billion in August -- down from a $1.85 billion deficit in July and the smallest red-ink figure since May, 1976.

Moreover, the improvement came despite a pickup in U.S. purchases of foreign petroleum, which bounced upward by 8.1 percent in dollar terms -- or 6.2 percent in volume -- after plunging sharply in July.

The decline in the deficit marked the third month in a row that the red-ink figure has shrunk. As late as last May, the deficit still was $3.9 billion. It fell to $2.28 billion in June before narrowing further in July. Commerce Secretary Phillip M. Klutznick issued a statement predicting that the trade deficit for all of 1980 would end up "no greater than -- and perhaps $2 billion to $3 billion below"-- the $37.29 billion red-ink figure of 1979.

Klutznick noted that many economists -- including some in the Carter administration -- had forecast that the deficit would climb sharply higher this year because of skyrocketing crude oil prices.

However, increased conservation -- and a resulting drop in import levels -- apparently have altered that prospect.

Encouraging to economists was that the improvement in the trade balance stemmed primarily from another increase in American exports, which surged $1.05 billion or 5.7 percent in August to $19.10 billion -- from $18.08 billion in July.

The sharp boost in exports was spread throughout the major categories and industries the department surveys each month, with especially heavy shipments of wheat and other agricultural commodities. s

Export levels had declined 3 percent in July after rising 5.5 percent in June. American sales overseas have turned in a mixed performance over the first eight months of this year. Yesterday's figures showed across-the-board gains.

The import figures reflected a decline in U.S. purchases of foreign-produced autos, including those from Canada.

Yesterday's statistics were compiled on the new "C.I.F." method of calculation, which includes the cost of the goods.

A new law pushed through Congress by Senate conservatives prohibits the department from reporting imports on the traditional basis for another 48 hours. The trade deficit appears worse under the new calculations.

The latest figures brought the cumulative trade deficit for the first eight months of this year to $24.51 billion, compared with a $23.36 billion red-ink figure at this time in 1979.

U.S. exports have been rising sharply for two reasons: The relatively low value of the dollar on foreign exchange markets has made them more competitive, and faster growth in Europe and Japan has made them more eager to import.

Despite the increase in oil imports last month, American purchases of foreign petroleum remained at relatively low levels in August, rising to 186,346 million barrels of foreign oil. At its peak last February, the total was 256,812 million.