Unidentified gunmen kidnaped the U.S. director of the American University Hospital, Beirut's largest, on his way to work today as heavy fighting continued for control of three major Palestinian refugee camps.

David Jacobsen, 54, became the sixth American to be seized or to disappear in the Moslem-controlled sector of the Lebanese capital since March 1984.

The abduction, for which no group had claimed responsibility by late tonight, brought new warnings from Washington that Beirut is unsafe and Americans should leave.

At the refugee camps on the southern edge of Beirut, where Shiite Moslem forces and Palestinian guerrillas have been fighting since May 19, a Palestinian attack on Shiite forces at a mental hospital today set back attempts to reach a truce and refueled clashes with rockets and tank shelling.

Akef Haidar, head of the politburo of Amal, the Shiite militia, charged that Palestinian guerrillas entered the Islamic Ijjaz Hospital adjoining Shatila, one of the three camps, and killed 21 Amal fighters and soldiers of the Lebanese Army's predominantly Shiite 6th Brigade after drugging them with tea containing sedatives.

Abu Ahmed, a spokesman for the National Palestinian Salvation Front, a coalition of pro-Syrian guerrilla factions, called Haidar's account "ludicrous." He said a fierce battle had taken place in the hospital after Palestinians heard that Amal had seized it and killed wounded fighters who had sought refuge there. "Our men inflicted some casualties in today's battle but retreated," Abu Ahmed said. "The hospital is now in Amal hands."

An Amal militia source later said that only three Amal fighters had been killed at the hospital, Reuter reported.

Fighting also continued at Shatila, which adjoins Sabra, and at Burj al Barajinah, south of the other camps and near the Beirut airport.

Abu Ahmed said guerrillas entrenched in the densely populated Burj al Barajinah camp, the only one of the three still controlled by the Palestinians, had beaten back at least four attempts by the Army's 6th Brigade and Amal to burst through its defenses. Palestinian sources say there are 3,000 fighters in Burj al Barajinah, which usually houses about 25,000 civilians.

Efforts to negotiate a truce have been deadlocked because of Palestinian refusal to turn over their weapons to Lebanese Army soldiers. The Shiite militia has said it attacked the camps to prevent the Palestinians from reestablishing themselves militarily there and in predominantly Shiite southern Lebanon.

In Tunis, Abdel Hamid Sayeh, speaker of the Palestine National Council, the parliament-in-exile of the Palestine Liberation Organization, said the PLO was eager to end the fighting and was studying Amal cease-fire proposals but that it would not accept Palestinian disarmament as a cease-fire condition, Reuter reported.

Witnesses to the abduction of Jacobsen said the gunmen, waiting in a blue van outside the entrance to a hospital staff parking garage, intercepted him and stashed him in the back of their vehicle, after firing a shot at the feet of a doctor who was accompanying him. As of late tonight, there was no indication of his whereabouts although intense negotiations were under way with various armed factions.

Jacobsen had just crossed the street separating the American University of Beirut campus, where he lives, from the main buildings of the 420-bed hospital, which has been jammed in recent days with casualties of the fighting in the city and the camps. The campus is in an area controlled by militias of Amal and the Druze Progressive Socialist Party.

Despite a surge in kidnapings of westerners in Beirut in March, Jacobsen, who arrived here Dec. 1, said in an interview last month that he would stay on because the hospital was so important for people around him.

"I know I cannot do anything dramatic to improve the situation, but my presence is a symbol of hope," he said in justifying his resolve to ride out the hazards of Beirut.

Jacobsen, from Huntington Beach, Calif., had stressed in private conversations earlier that he had decided to stay here not because he was "macho" but as a man of principle. "The overwhelming majority of the Lebanese people are good," he said. "They are being terrorized by a small group whose leaders find them difficult to control. I think eventually decent people will win their battles."

In Washington, State Department spokesman Bernard Kalb said a two-year-old advisory against travel by Americans to Beirut remained in effect. "We believe that Americans should avoid travel to Lebanon and Americans in Beirut should take advantage of opportunities to leave," Kalb said.

White House spokesman Larry Speakes said U.S. Ambassador Reginald Bartholomew had been in touch with Lebanese President Amin Gemayel and urged "a maximum effort by all concerned to win Jacobsen's safe and early release."

In London, the British Broadcasting Corp. said it has withdrawn its three correspondents from Beirut after they were threatened and the BBC "became concerned about their safety," The Associated Press reported. The BBC gave no details of the threats.

Other Americans kidnaped or missing in Beirut are Terry Anderson, the bureau chief of The Associated Press here; the Rev. Benjamin Weir, a Presbyterian minister; the Rev. Lawrence Jenco, the director here of the Catholic Relief Services; Peter Kilburn, a librarian at the American University, and William Buckley, a political officer at the U.S. Embassy who was seized by gunmen in March 1984.

The Islamic Jihad organization has claimed responsibility for these abductions. Earlier this month, it offered to release four of the Americans and two French diplomats in exchange for the freedom of some of its members held in Kuwaiti jails on bombing charges. Kuwait has rejected the request for the exchange.

On Jan. 8, 1984, Islamic Jihad claimed responsibility for the assassination of Malcolm Kerr, the acting president of the American University of Beirut.