The House and Senate, angered by Iran's military actions in the Persian Gulf, overwhelmingly approved legislation yesterday banning the importation of Iranian products into the United States.

On a 93-to-0 vote, the Senate approved a bill that would immediately bar any further Iranian imports, primarily oil, unless the president finds such a prohibition would not be in the national interest. The president would be able to delay the embargo by six months at most.

The Senate vote was followed last night by House approval, 407 to 5, of similar legislation. However, before the bill goes to President Reagan, minor differences between the two versions must be reconciled in a conference between the House and Senate.

Although there has been a sharp increase in U.S. imports of Iranian oil in recent months, even supporters of the ban conceded it would be little more than a symbolic gesture unless other oil-importing nations followed suit.

"What it says to me is we can assuage our anger, we can make a statement, but we won't solve our problems until we make ourselves energy independent," said House Speaker Jim Wright (D-Tex.).

Nonetheless, lawmakers said it was vital for the United States to do what it could to prevent Iran from using the hard currency derived from oil sales to fuel its prolonged war with Iraq and to lay mines that threaten U.S. shipping and naval forces in the Persian Gulf.

"It will not cause the war to end, but it will send a strong message," said Rep. William S. Broomfield (R-Mich.), the ranking Republican on the Foreign Affairs Committee.

The House version of the legislation authorizes Reagan to negotiate with other nations to persuade them to join the ban.

Oil accounts for about 90 percent of U.S. imports from Iran. Other products are rugs and pistachio nuts.

Though Iran was the nation's second largest oil supplier during July -- when $359 million worth of Iranian oil was imported here -- it has historically been a far smaller provider. The United States normally buys about 5 to 10 percent of its overseas supply from Iran.

Total oil imports from Iran were just under $500 million in 1986, but reached $819 million through the first seven months of this year.

Though the Reagan administration has taken no formal position on the legislation, Senate Minority Leader Robert J. Dole (R-Kan.) said some officials are opposed.

"If rumors are to be believed, there continues to be opposition to this import embargo in some parts of the administration, especially in the State Department," said Dole. "So it is doubly important that the Congress go on record overwhelmingly in favor of an embargo and present the question to the administration in a fashion that it cannot be ducked."

Dole last week sponsored a similar ban that was attached to the Defense Department authorization bill. But Reagan is expected to veto that bill for other reasons.