The United States and the European Community yesterday ended months of dispute by agreeing to a 25 percent reduction in imports of certain European steel products.

The agreement restricts the importation of 16 European steel products to 475,000 tons annually. The deal was viewed as a victory for the Reagan administration, which had pushed for that limit, against the 540,000-ton figure sought by the Europeans, sources said.

In a cabinet-level meeting on Tuesday, the State Department and Council of Economic Advisers had attempted to end the dispute by yielding to the Europeans' demand, sources said. However, Commerce Secretary Malcolm Baldrige argued that U.S. negotiators would lose leverage in other talks if they gave in.

The U.S. officials agreed to make a final offer of 475,000 to the Europeans. If it wasn't accepted, the United States would impose its own restrictions, sources said.

The dispute concerns 16 categories of steel products not covered under a 1982 agreement limiting imports of other steel products. The items not covered were wire products, semi-finished steel, cold-finished bar and other specialized products.

The products excluded from the agreement were referred to as consultation products because the agreement provided that if European steel exports were diverted from the covered products to those excluded from the arrangement, both sides would then consult on what measures should be taken to prevent the diversion.

Semi-finished steel was not included in the announcement yesterday. The United States is evaluating restrictions on those products separately, officials said.