YORK, Pa. — President Reagan, riding the successful efforts of Harley-Davidson to fight Japanese motorcycle competition with the help of limited government tariffs, campaigned Wednesday against mandatory trade sanctions.

"American workers don't need to hide from anyone," he said.

The President made a brief trip to this small industrial city in southern Pennsylvania to draw attention to what he views as the role that limited trade tariffs and quotas can play in helping beleaguered American industry. He is fighting stiffer trade legislation approved by the House last week.

An amendment introduced by Rep. Richard A. Gephardt (D-Mo.) that was attached to the measure would require retaliatory trade sanctions to be imposed against nations that fail to reduce large trade surpluses with the United States.

"Our trade laws should work to foster growth and trade, not shut it off. And that is what is at the heart of our fair trade policy: opening foreign markets, not closing ours," Reagan said. "The idea of going to mandatory retaliation and shutting down of presidential discretion in enforcing our trade laws is moving toward a policy that invites, even encourages, trade wars."

The President's audience--assembly-line workers, shippers, company managers and other employees, who had cheered his praise of Harley-Davidson motorcycles--was nearly silent while he criticized the trade legislation intended to protect the jobs of American workers facing overseas competition.

Modernization Noted

Reagan, who in the past has opposed all forms of "protectionist" trade limits in favor of free competition in the international marketplace, praised the efforts of the Harley-Davidson management and workers to modernize their production and improve the quality of their work while the government raised the duties on the larger Japanese motorcycles that were its chief competition.

On April 1, 1983, acting on the recommendation of the International Trade Commission, the President imposed five years of tariffs after the Japanese cycles swamped the American market. On March 18 of this year, Harley-Davidson, now the only U.S.-based motorcycle manufacturer, declared itself on sound enough footing that it no longer needed the protection.

In the course of the company's modernization, the work force at the York factory was reduced to about 1,100 from the approximately 1,800 who worked there at the end of 1982. And the company's share of the U.S. market for the largest motorcycles increased from 23% in 1983 to 33.3% last year--leading all competitors.

Hearing Scheduled

The trade commission has scheduled a hearing for later this month to consider lifting the sanctions.

"You asked us to give you breathing room so you could finish getting into shape to meet unexpectedly strong foreign competition. So when I was told that you wanted a little more time to train, I said, 'Yes, kick on the engine, Harley. Turn on your thunder,' " the President declared, standing at a podium erected in a warehouse.

With more than a dozen shipping cartons and six gleaming motorcycles--Harley "hogs" ranging from $3,995 to $10,000--forming a backdrop, Reagan said: "There are some in Congress who say, in effect, that the United States should break its word with the other countries.

"They say American workers need to run and hide from foreign competition, even if that means other countries will strike back by not letting you sell your bikes to their people."