MANAMA, Bahrain (AP) _ Crewmen of the USS Stark knew an Iraqi pilot had the frigate locked on radar but apparently did not realize he had launched a missile, the commander of the Navy's Persian Gulf task force said Tuesday.

Rear Adm. Harold J. Bernsen, who was on his flagship destroyer Lasalle at the time of the attack, said the surprise must have been ''incredible'' when a missile struck the Stark. The attack Sunday night off the emirate of Qatar killed 37 American sailors and wounded 21.

Bernsen, who has six other ships in his command, told reporters preliminary information indicated the Stark had no advance warning an attack was under way.

At nightfall Tuesday, the crippled guided-missile frigate stood off Manama under tow, flying the Stars and Stripes at half-staff.

The admiral said it did not appear that the crew tried to fire at the Iraqi plane or missiles and he did not think the captain, Cmdr. Glenn R. Brindel, was on the bridge at the time.

He said it was not clear whether the missiles were Exocets and thus of a type that could have been picked up by the Stark's radar and weaponry systems.

Asked whether he was saying the crew had no idea the rockets had been launched, he replied: ''That's precisely what I'm saying.''

When asked if he knew why no weapons were fired in self-defense, Bernsen replied: ''No, I really don't. I think that the surprise was incredible, quite frankly.''

One crewman on lookout saw a missile coming and gave a warning, he said, but ''toward the end it became evident nothing could be done. ... a great amount of detail needs to be worked as to why it (the Stark) did not respond.'' He said the attack caused a ''tremendous amount of damage and immediate deaths.''

In Washington, White House chief of staff Howard Baker asked why a ''trigger-happy'' Iraqi pilot fired at the guided-missile frigate. He restated the American view that free navigation in the Persian Gulf is essential.

The attack Sunday night was the first on an American warship in the gulf since U.S. vessels began operating in the area in 1949 and the deadliest on shipping since Iran and Iraq went to war in September 1980.

President Saddam Hussein of Iraq sent President Reagan a letter expressing ''deepest regret over the painful incident.''

Iraqi Foreign Minister Tariq Aziz said the war ''will bring more tragedies'' like the Stark unless the U.N. Security Council finds a way to end it. Hussein, who started the war with an invasion, has sought peace in recent years but Iran vows to fight until he is driven from office.

The speaker of Iran's Parliament, Hashemi Rafsanjani, claimed the Iraqi attack resulted from a plot by the United States, Saudi Arabia and Iraq to put the blame on Iran.

Nearly 230 ships have been hit by Iran or Iraq since attacks on commercial shipping began in February 1984.

Bernsen said 24 of the dead had been identified, 11 identifications remained to be made and two crew members were missing and presumed dead.

He said the Stark's crew had not determined ''hostile intent'' by the Iraqi warplanes and they were considered ''friendly aircraft.''

''We are not here to shoot friends or indiscriminately,'' he said, and called the attack ''a very unfortunate error. ... As Americans we deal with the world, we presume people are not out there to shoot at us.''

The task force commander said Iraqi pilots had flown 340 missions of ''similar profile'' in the past nine months, firing 90 Exocet missiles and striking 40 ships or other targets.

Associated Press Radio correspondent Steve Katz, who viewed the Stark from a boat about 200 yards away, said the bridge was ''all twisted metal.''

He saw a gaping hole under the bridge. A few U.S. Navy men were busy around the damaged area and two dozen stood on the undamaged rear decks.

Reporters taken on the boat trip organized by the Bahrain government were not allowed to get closer because the Stark and its towing vessel, the USS Conyngham, needed room to maneuver.

Bernsen said the Stark was five nautical miles from the Manama port. He said a damage assessment team would inspect it Wednesday and decide whether it should be brought in.

''There are still hot spots but no fire,'' he said, adding the engine room and helicopters were in good shape but the missile room had to be flooded after the attack. The frigate is ''on an even keel and floating well,'' Bernsen said.

A marine salvage executive said that, just after the attack, ''the inside of the Stark got so hot that the aluminum was melted. During the fire it was like the inside of a boiler,'' with a temperature of 1,832 degrees.

The bodies were on the USS Lasalle and a U.S. Air Force C-141 transport jet was due Wednesday to take them home via Europe.

Reagan put U.S. forces in the gulf on heightened alert Monday and warned Iran and Iraq their jets will be shot down if they threaten American ships.

The 453-foot Stark, which carries a crew of 200, and the other six ships in the task force are assigned to patrol the gulf and the Strait of Hormuz, its southern gateway, through which about 20 percent of the non-communist world's oil passes.

British and French warships also patrol the area.

In his comments in Washington, Baker called the gulf ''absolutely essential to the vital interests of the United States and the free world.''