The United States piled up the largest trade deficit in its history last year as a flood of imports, drawn in by the strong dollar, overwhelmed modest increases in overseas sales by American companies, the Commerce Department reported yesterday.

The unprecedented trade deficit, expected to surge even higher this year, provided the only black cloud in the otherwise robust economic recovery and is sure to increase protectionist pressures on the Reagan administration.

The trade deficit totaled $123.3 billion last year, nearly double the 1983 record of $69.4 billion and almost three times greater than 1982's $42.7 billion deficit.

Last year's $36.8 billion trade deficit with Japan, the highest with any country, was greater than the United States' entire trade deficit as recently as 1980.

The United States also is running a substantial deficit in the broadest measure of foreign trade, the current account on international transactions, which includes trade in services and interest payments on investments abroad as well as merchandise trade. That figure ran a $32.9 billion deficit for the third quarter and, when fourth-quarter totals are released, probably will show a record of more than $100 billion for the year because the trade surplus in services is no longer able to cover the merchandise trade deficit.

The trade figures reflected the strong dollar, up 40 percent since 1980. Imports soared 26.4 percent last year, to $341.2 billion, while exports increased just 8.7 percent, to $217.9 billion.

With the price of foreign products lowered by the strong dollar, Americans bought increasing amounts of manufactured goods from abroad -- including cars, up 27.2 percent; electrical machinery, up 46.5 percent; telecommunications equipment, up 41.3 percent, and iron and steel products, up 61.1 percent.

The United States recorded an $88.5 billion deficit in manufactured goods, more than twice last year's $38.2 billion shortfall in an area where there used to be a healthy surplus.

There were increases in exports of some manufactured goods, including office and electrical machinery, chemicals and cars, while U.S. farmers sold $38.2 billion more in agricultural products overseas, a jump of 4.8 percent. But farm imports also increased, cutting the agricultural trade surplus by 10 percent, to $16.7 billion.

Besides Japan, the United States ran major deficits with Canada ($20.4 billion), Taiwan ($11.1 billion), West Germany ($8.7 billion), Mexico ($6.3 billion) and Korea ($4 billion). The deficit with all OPEC nations totaled $13.7 billion, while the United States ran a $1.6 billion surplus with Saudi Arabia.

The deficit drew unusually harsh reactions from business groups as well as Republican and Democratic lawmakers.

Jerry Jasinowski, chief economist of the National Association of Manufacturers, called the trade deficit "a disaster" that "is subtracting from the country's overall economic growth" and "radically changing the way American firms are doing business" by "driving more and more of them abroad."

Sen. John C. Danforth (R-Mo.), chairman of the Senate Finance Committee's trade panel, said he is particularly disturbed by the increased imports of manufactured goods and the "disproportionate share . . . attributable to a few countries, such as Japan."

Sen. Lloyd Bentsen (D-Tex.), who heads a new Senate Democratic working group on trade, called for new trade policies to find ways to force other countries to open their markets to American products.

Another Democratic congressional trade specialist, Rep. Donald J. Pease (D-Ohio), said the trade deficit costs about 2.2 million American jobs.

The only bright spot was the improved picture for the last quarter, when the deficit ran at a slower rate than the third quarter, which was an annualized rate of $146 billion. December's $8.2 billion deficit was the lowest of the year, down from November's $1.7 billion.