The United States and its closest Western European allies reached a last-minute agreement yesterday in a dispute over limits on steel imports..

But no sooner had the steel trade problem been solved than a new "pasta war" erupted between the United States and Europe with a barrage of retaliatory moves from both sides of the Atlantic.

The United States sharply increased tariffs on European pasta in retaliation for restrictions on sales of U.S. citrus products. The EC then retaliated by increasing duties on imports of U.S. lemons and walnuts.

The steel agreement, involving $2.5 billion in EC exports to the United States, was by far the most important event in a day of tense negotiations between the United States and the 10-nation European Community.

Under the new agreement, the Europeans said they would limit their steel shipments to 5.5 percent of U.S. market, which EC External Affairs Commissioner Willy de Clercq said in Brussels would protect "the essential interests" of the community's steel makers.

"We have been able to keep the peace. Our negotiations have yielded a satisfactory result," said an exhausted de Clercq after an all-night negotiating session.

Covered by the new restrictions, which will continue for four years, are 33 separate catagories of steel products -- 21 more products than were covered in a 1982 agreement. In addition, the new agreement includes an extension of restrictions on imports of pipes and tubes.

U.S. Trade Representative Clayton Yeutter called the settlement "a major acomplishment for the president's steel program as well as a major step forward for trade relations between the United States and the EC.

"The scope, duration and levels of the agreement will preserve the integrity of the president's steel program, which provides for voluntary restraint agreements on steel shipments to the U.S. from the major steel-producing areas of the world," he continued.

President Reagan's program to give the U.S. industry import relief so it can modernize to become internationally competitive, calls for foreign steel to take about 18 1/2 percent of the American market -- a goal that was exceeded this year but experts say is likely to be reached in 1986.

The EC pact is the 15th agreement on steel to be negotiated with major suppliers since October 1984. Yeutter said imports from the 14 countries already covered by agreements declined by 14.4 percent during the first nine months of the year.

Yeutter said the EC agreement sets limits that are 20 percent below the 6.6 percent share of the U.S. market the Europeans had captured during the first nine months of this year. On Thursday -- before the agreement was reached -- Yeutter called the surge in EC shipments "unconscionable violations" of the spirit of the 1982 agreement.

The American steel industry, however, expressed disappointment with the agreement. Donald H. Trautlein, chairman of the American Iron and Steel Institute and head of Bethlehem Steel Corp., said giving EC steel makers 5.5 percent of the American market fails to "penalize" them for "persistent violations" of a 1982 agreement on steel imports.

One specific objection from the U.S. steel industry concerned semi-finished steel, which is shipped to this country for further processing. The Americans wanted specific limits on that product in the agreement, but the Europeans balked.