In a test of his authority over clerical hard-liners, President Abol Hassan Bani-Sadr today stripped Islamic judge Ayatollah Sadegh Khalkhali of his judicial title and powers for defying a presidential ban against demolishing a mausoleum built by the deposed shah, Mohammad Reza Pahlavi.

In another development, several American helicopters flew over Iranian ships working in Persian Gulf oil fields, but switched their course after the Iranian armed forces were alerted, Iranian radio reported. The Pentagon denied the Iranian report.

Khalkhali, dubbed "Judge Blood" for his role in sentencing hundreds of former officials and supporters of the shah to their deaths, was relieved of all authority except that of his recent appointment as chief of an antinarcotics campaign.

In a brief announcement broadcast by the state radio, Bani-Sadr said Khalkhali, 57, will no longer enjoy judicial powers.

The move came after Khalkhali defied the president's ban on the demolition of a marble mausoleum that the deposed shah built for his father 20 years ago and enlisted volunteers and bulldozer crews to tear down the building.

Bani-Sadr had ordered that the building be preserved and turned into a "monument to the crimes" of the shah and his father who, between them, ruled Iran for 55 years until last year's revolution.

Official sources said that although Bani-Sadr was angry at Khalkhali's disregard of the ban, the issue of who exercises authority in Iran was more important than the matter of the mausoleum itself.

If Bani-Sadr can make his order stick, the sources said, it may help him consolidate his position in advance of the next major challenge he is likely to face when the new Iranian parliament -- controlled by Islamic hard-liners like Khalkhali -- convenes next month.

The outcome of the test of rival strengths could also affect the fate of the American hostages, who have reportedly been dispersed by their Islamic captors to several cities around Iran.

Iranian leader Ayatollah Ruhollah Khomeini has ruled that the fate of the hostages will be decided by the parliament, which following Friday's election appears to be firmly controlled by the clerical Islamic Republican Party and its Moslem fundamentalist allies.

In reporting on the incident involving American helicopters, the Soviet news agency Tass quoted the Tehran newspaper Bamdad as saying five U.S. Navy helicopters dropped a foamy chemical substance over the Persian Gulf, causing a large fire on the water near the Iranian coast.

[The United States has about two dozen ships off Iran, including aircraft carriers from which helicopters can take off. The Pentagon, however, denied that there were helicopters in the area.]

Iranian Oil Minister Ali Akbar Moinfar said security at Iran's oil fields would be increased following the reported incident and Tass denounced the "new provocation by the American military" as "fresh proof of the fact that Washington continues to make plans for new military ventures against Iran."

Tehran radio also quoted the commander of the Bandar Abbas Air Base in southeastern Iran near the Strait of Hormuz as saying there had been a military intrusion of an unspecified nature in their area tonight. The report said workers at two oil refineries had observed the intrusion and that the Iranian Navy had confirmed it.

Moinfar also said that Iran is now producing 2 million barrels of oil a day, one of the lowest levels conceded by Iranian officials since the fall of the shah. During the shah's rule, as much as 6 million barrels a day was produced.