The Reagan administration said yesterday that Iran may have acted within the bounds of international law Sunday when it halted and searched a U.S. merchant vessel near the Persian Gulf. Although two U.S. warships subsequently sailed to the area, U.S. officials played down the incident and said the United States is not seeking an escalation of tensions with Iran.

White House spokesman Larry Speakes and State Department spokesman Bernard Kalb, citing identical policy guidance, said that "the rules of naval warfare have traditionally accorded a belligerent certain rights to ascertain whether neutral shipping is being used to provide contraband" to an opponent. Iran has been at war with Iraq for more than five years.

Both Speakes and Kalb added that the United States is seeking to determine whether the Iranian action in halting the 39,000-ton President Taylor "was appropriate under the circumstances." They said that until the investigation is completed, the United States will not comment about any possible responses.

However, the spokesmen cited the incident as "a significant negative consequence" of the Persian Gulf war. They also criticized "Iran's intransigent refusal to participate in a negotiated settlement" and reiterated U.S. calls for "Iran to change its position regarding a solution to the conflict."

After the outbreak of the Iran-Iraq war, the United States declared neutrality. However, the Reagan administration since has resumed diplomatic relations with Iraq and has spearheaded a campaign to get other countries to halt arms sales to Iran on the grounds that denying Tehran the means to continue fighting could force it into peace negotiations.

Earlier yesterday, Defense Secretary Caspar W. Weinberger told reporters that two U.S. warships -- identified by Defense Department officials as the destroyer USS Conolly and the frigate USS Boone -- responded to a call for help from the President Taylor but arrived after the Iranians had left. The boarding and search took 1 hour and 45 minutes, according to a Pentagon official.

"We sent some units at the request of the merchant ship," Weinberger said. "The American ship is entitled to call on the Navy for protection. They did, and we responded."

The boarding took place shortly after the aircraft carrier USS Saratoga left the region for Mediterranean duty, leaving U.S. forces without air power for the first time in several months, Pentagon officials said. One source speculated that the Iranians, who keep a close eye on ship movements in the Persian Gulf and the Gulf of Oman, had waited until the carrier left before moving against an American ship.

Reports from the United Arab Emirates port of Fujaira, where the President Taylor subsequently docked, quoted sources as saying the Iranians had threatened drastic measures if the ship failed to yield to a search. However, the reports continued, the Iranians behaved politely during the search, and no violence was reported by the 43-member crew of the President Taylor, which is operated by the American President Lines of Oakland, Calif.

British authorities in London reported that a British freighter, Barber Perseus, also was stopped by Iranian naval commandos Sunday while en route to Kuwait in the Persian Gulf. The vessel was released after a scrutiny of its manifest, according to the reports from London.

Kalb and Speakes noted that the Iranian practice of stopping neutral shipping in or near the Persian Gulf over the past five months has involved vessels from Kuwait, Italy, West Germany, Denmark, Yugoslavia, Poland and Japan. The President Taylor, which was carrying cotton and other general cargo, was the first American ship to be involved in such an incident.

International law holds that as a general principle a country at war has the right to search cargo ships for suspected military equipment in a war zone if it has declared its intention to do so, and, as a result, neutral ships entering such a zone do so at their own risk.

Pentagon sources said that preliminary information indicated that the Iranians, in boarding the President Taylor, appeared to have behaved correctly except for forcing the crew to break off radio contact.