The nation ran another huge trade deficit last month, although the $2.3 billion imbalance was smaller than the record $2.8 billion deficit recorded last June.

The Department of Commerce said that much of the narrowing in the deficit in the trading account with other nations came about because of a $300 million decline in purchases of foreign oil.

Continuing large trade deficits reinforce the arguments of industries and unions who seek increased protection from foreign competition. In the first seven months of the year, the nation has imported $14.9 billion more than it has exported.

Before this year, the biggest U.S. trade deficit on record was $6.4 billion in 1972. Officials now anticipate that the trade deficit for 1977 will be $25 billion or more.

The Carter administration, for the most part, has been fighting a growing tide of protectionist sentiment among workers and businessmen. Officials argue that the big and persistent deficits are not an indication that the U.S. is becoming less competitive in world markets or the foreign countries are unfairly dumping their products here.

Instead, they say, the red ink the nation has recorded in its trade ledger in each of the last 14 months is in part due to oil imports and in part to a stronger recovery here than in Western Europe and Japan.The U.S. recovery has boosted this nation's demand for imports while weaker recoveries abroad have not stimulated like demand for American products.

As foreign economies pick up, demand for goods produced in the U.S. should also increase, officials contend.

White House press secretary Jody Powell said that the narrower July deficit was "mildly encouraging," but said it is too big. Even though oil imports declined to about $3.6 billion from $3.9 billion, they were "still very high," he said.

Powell noted that oil imports may slow in the future as some foreign oil is replaced by oil from the North Slope of Alaska and as petroleum companies reduce their inventory buildups. Because there is a surplus of gasoline oil companies reduced gas prices.

According to the Commerce Department, imports in July totalled $12.47 billion, compared with $12.93 billion in June. Much of the decline was due to smaller oil imports, but the Commerce Department report said that nine of the 10 broad import categories had declined in July.

There was also a sizeable decline in imports of coffee as American consumers continued to resist sharply higher prices for the beverages.

The only broad import category to register an increase was machinery.

U.S. exports were almost static, rising slightly from $110.11 billion in June to $110.49 billion in July. Five of the 10 export categories registered an increase and five declined.

Increases in exports occurreed among electtrical equipment, military aircraft, office machines, chemicals, coal and plastics. There was also an increase in wheat exports.

For the year to date, imports have totaled $85 billion and exports are $701.1 billion. Through the first seven months of 1976, exports were $65.6 billion, imports were $67.22 billion and the deficit was $1.6 billion.

Courtenay M. Slater, chief economist for the Commerce Department, said that the narrower deficit in July was anticipated because the record June deficit was above the trend.