There has been a rising consensus in the Government that if there was ever a case for protecting an American industry, this was it.

The United States, after losing its dominance in steel and automobiles, is still clearly ahead in computers. The fear in Washington is that if the nation lost this advantage, other large American industries - such as telecommunications and military electronics - would be crippled. Years of Frustration

The issue also came to a head because of years of frustration over trade discord with the Japanese and the bulging American trade deficit, which has cost many manufacturing jobs in the United States.

Mr. Reagan said the action was being taken ''to enforce the principles of free and fair trade'' and could be eliminated if Japan stopped the reported unfair trade practices.

Under the semiconductor agreement, Japan said it would not sell its chips in the United States or other nations below fair market value and would allow greater access to American chip makers in the Japanese market. The American view that the Japanese did not comply with the pledge led to the tariffs.

''We will eliminate them as soon as we have firm and continuing evidence that the dumping in third-country markets has stopped and that access to the Japanese market has improved,'' President Reagan said.

A senior White House official said Mr. Reagan had arrived at the $300 million tariff based on a formula that penalized Japan $165 million for sales that American industries would have had if Japanese markets had been open and $135 million for lost American business in third countries because of Japanese dumping.