President Reagan threatened yesterday to place restrictions on imports from the European Community in retaliation for actions that could jeopardize as much as $1 billion in U.S. farm sales to Spain and Portugal.

An EC official said that any U.S. retaliation could lead to a transatlantic trade war.

"Unless the community rescinds its illegal quotas and promptly provides compensation for its increased tariffs, the U.S. will offset the new restrictions by establishing quotas and increasing tariffs on EC products entering our market," said White House spokesman Larry Speakes at the vacation White House in Santa Barbara, Calif.

The presidential action was quickly attacked by EC External Affairs Minister Willy de Clercq, who called the U.S. threat "unfriendly, needlessly aggressive and difficult to understand.

"This confrontational approach risks leading to open commercial conflict even though the community has declared itself ready to negotiate," De Clercq added in a statement released by the EC's Washington office.

The heated war of words intensified trade frictions that have developed in recent months between the United States and its closest allies in Western Europe over a variety of issues that include agriculture, steel, telecommunications and passenger jets. Administration officials have complained that the European Community is turning more protectionist even as it denounces protectionism in the United States and while other nations, including Japan, have rolled back some of their trade barriers.

President Reagan said yesterday's actions are "aimed at eliminating foreign unfair trade practices and securing open markets for U.S. exports."

They are directed against actions that the EC has taken since Spain and Portugal joined the 10-nation Common Market this year. The Portuguese restrictions are quotas on oil seeds and oil-seed products -- largely soy beans -- and a requirement that Portugal buy 15 percent of its grain from within the EC.

Deputy U.S. Trade Representative Alan Woods said both EC actions affecting Portugal -- which were taken to ease the transition of a nation that produces edible oils in a Common Market that already suffers from a glut of olive oil -- are illegal under the General Agreement on Tariffs and Trade, the international agency that sets rules for world trade. De Clercq, however, said GATT allows the EC actions.

If the EC refuses to rescind those moves, the United States will place quotas on European imports to make up for the quotas on soybeans, and increase tariffs on European products to make up for the grain quotas, Reagan said. These will be designed to inflict the same commercial harm on the EC that its quotas and tariffs cause U.S. farmers.

Spain's restrictions would increase tariffs on grain imports, which the president said the United States will meet by withdrawing an agreement not to raise tariffs on its purchases from the community. If the EC fails to provide "adequate compensation" by July 1, the United States will make up for the loss by actually increasing tariffs.

The EC has offered to negotiate the question of compensation, but De Clercq said, "this proposal has not so far received a response." He added that the total effect of enlarging the EC by adding Spain and Portugal has to be taken into effect, including possible gains by U.S. manufacturers because some tariffs will be lowered.

"The United States will derive considerable benefits from the enlargement of the community, not only in terms of trade, but also from the political standpoint since enlargement will reinforce the western alliance," De Clercq said.

In his statement, Speakes said the United States supports the enlargement of the EC, but does not believe "the EC should use this occasion to impose new trade barriers. Americans should not have to pay for the benefits which EC member states will enjoy."

In two other trade actions yesterday, Reagan directed U.S. Trade Representative Clayton Yeutter to investigate trade-distorting requirements by Taiwan that auto makers there export a percentage of the cars and whether EC rules "unfairly penalize" U.S. meat shippers and cost them as much as $125 million in European sales.