An armed Iranian Navy boarding party, apparently searching for war materiel headed for Iraq, detained and searched a U.S. merchant ship for two hours yesterday in international waters near the Persian Gulf, the State Department said.

A White House spokesman said that while full details of the incident were not available, the Reagan administration considers the boarding "a matter of serious concern." President Reagan was told of the Iranian action before his return yesterday afternoon from a weekend at Camp David.

The President Taylor, a 39,000-ton cargo vessel owned by American President Lines Ltd., continued sailing to Fujaira, a United Arab Emirates port on the Gulf of Oman, where Capt. Robert Reimann and his crew are to be questioned today by U.S. diplomats.

An official of the company in Oakland, Calif., said the 605-foot-long vessel with a crew of 43, mostly Americans, was about 30 miles from Fujaira in the Gulf of Oman when the incident occurred. He said the President Taylor had little cargo on board.

The spokesman said the ship, which left Seattle in late September to stop at various Asian ports, was not scheduled to go to Iraq. The vessel was bound from Karachi, Pakistan, to Fujaira, where it is to pick up CARE and Catholic Relief Services supplies for humanitarian work in India.

The State Department's Bruce Ammerman said no injuries or property loss occurred during the boarding, in which seven armed Iranian Navy men -- three officers and four sailors -- spent about two hours looking at several cargo containers before releasing the vessel.

Ammerman reported that Reimann told a U.S. diplomat in Abu Dhabi by radiotelephone that he acceded to Iranian orders after they threatened "drastic action" if he did not stop his ship and allow them to board. Reimann said he had warned the Iranians that their action was a violation of international law.

The department spokesman said the President Taylor's captain described the boarding party as "businesslike, nonthreatening" as they inspected the ship's manifest and several of its cargo containers.

Reimann reportedly had avoided a straight-line course as he entered the Gulf of Oman, which separates Iran and Oman below the narrow Strait of Hormuz at the southern end of the Persian Gulf. The captain took a more circuitous route to avoid a boarding incident, Ammerman indicated.

Ammerman said that yesterday's incident was the first involving a U.S.-flag vessel as part of an Iranian policy of challenging and, in some cases, stopping and searching merchant vessels in and around the Persian Gulf in an effort to intercept military supplies bound for Iraq, Iran's enemy in a five-year-old war.

Although the United States has been critical of the Iranian policy, the practice of stopping merchant vessels at sea is not uncommon. The United States, in its campaign to prevent the smuggling of drugs into this country, has routinely stopped foreign ships, particularly in the Caribbean.

Iran began stopping vessels entering the Persian Gulf in September after Iraq carried out heavy bombing raids on Iranian oil facilities at Kharg Island in August. The Tehran government warned that it might try to close the Strait of Hormuz to sea traffic if Iraq attacked Kharg Island.

The United States, Britain and France maintain naval forces in the area of the Gulf of Oman, through which about two-thirds of the West's oil moves. The Iranian policy of boarding merchantmen apparently has produced few incidents.

But in October, the Iranians were thwarted by the French Navy when they challenged a French freighter moving past Hormuz into the Persian Gulf.

The French military vessel warned the Iranians that a detention or boarding would not be permitted, and the ship continued on without incident.