The Reagan administration has decided to expand its Persian Gulf policy to allow U.S. warships to aid neutral merchant ships under attack, administration officials said Friday.

The policy is aimed at deterring Iranian attacks against gulf shipping and is a direct result of the mining of a U.S. frigate and Monday's extensive fighting between Iranian and U.S. forces, the officials said.Under the new policy, for which support is being sought from congressional leaders and allied governments, Navy warships would no longer be told to ignore Iranian attacks on merchant ships that weren't flying the Stars and Stripes.

If a U.S. warship observed an Iranian attack and was close enough to intervene, it would have the authority to do so, said the officials, who agreed to discuss the matter only if not identified.

"It's a random, target-of-opportunity approach designed to throw the Iranians off guard," said one source.

Rep. Les Aspin, D-Wis., chairman of the House Armed Services Committee, confirmed that the new policy had been discussed Friday with the congressional leadership. He said the policy would "enable U.S. Navy vessels to defend themselves fully and to take appropriate action to deal with specific circumstances."

Although Aspin refused to discuss specifics of the policy, another Capitol Hill source who was briefed on the matter said, "This will give a lot of authority to local commanders and a lot of leeway to do as they see fit."

The new policy assumes that Iraq, at war with Iran for 71/2 years, will not attack neutral merchant ships operating between neutral ports. It thus is intended to apply specifically in cases of neutral merchant ships under Iranian attack.

"Our purpose is not to get into a war with Iran," said an official. "Our purpose is to secure safe passage for neutral shipping moving back and forth between neutral ports."

The sources stressed the policy change did not entail an extension of the U.S. military umbrella to foreign-flag ships in regular convoys. Even under the new policy, only ships flying the American flag will be entitled to "door-to-door protection" in convoys.

Also rejected in formulating the new policy were suggestions that Navy warships start protecting American-owned ships that fly a foreign flag of convenience, the sources said.

Because of those decisions, the Pentagon is hopeful it can avoid the assignment of additional ships to the gulf to implement the new policy, the officials said.

The new policy will extend in certain cases, however, to Western-operated oil rigs in the gulf, the sources said, refusing to elaborate.

The officials, citing the need "to keep Iran guessing," refused to say when the administration intended to implement the new policy. One source said it could happen "soon, maybe next week," but refused to elaborate.

Another official suggested the timing could still be affected by ongoing consultations with congressional leaders and with U.S. allies such as Britain and France with warships of their own in the region. This source added that congressional reaction so far had been "pretty positive."

Aspin declined to discuss specifics of the new policy, saying they were classified.

"The negative side of that classification is that the American public won't know what we will be doing. The positive side is that the Iranian government won't know what we will be doing," Aspin said. "In this case, I think the positives outweigh the negatives. We are trying to deter the Iranians from violent action in the gulf."

The officials indicated the administration had made up its mind on Friday, when the Pentagon secured the White House's blessing for the change.

"There is a decision in the sense that we know where we want to go now," said one official. "But we're still consulting with some people and it's not in our interest to offer details to Iran."

The change, which Defense Secretary Frank C. Carlucci and top aides began outlining on Capitol Hill on Friday, is a direct result of the mining of the U.S. frigate Samuel B. Roberts April 14 and last Monday's extensive fighting between Iranian and U.S. forces, the officials said.

U.S. forces sank or crippled six Iranian vessels that challenged them after they destroyed two offshore platforms in retaliation for the mining of the Roberts.

Top defense officials argued to the White House the United States had to do more to deter Iran from sowing additional mine fields in the gulf, said the sources. The Pentagon further argued that Iran's response to the U.S. strike on Monday "was so utterly intemperate, just lashing out," that something had to be done, one official said.

At one point Monday, Iranian gunboats began firing on oil rigs and Western ships in an oil field that had not been the scene of earlier fighting.

According to the sources, the upcoming changes will not affect the so-called "rules of engagement" the guidelines given Navy commanders spelling out the conditions under which they may shoot; for example, the need for radio challenges and the range between forces.

"This is an expansion of policy; the policy of who gets protection," said one.

The Reagan administration expanded its naval presence in the Persian Gulf last summer at the request of Kuwait, an ally of Iraq in the Iran-Iraq war which had seen its tankers become special targets of Iranian attack.