Three mortar rounds were fired at NATO warships anchored in Lisbon harbor early today but fell into the water 100 yards short of their target, police said, and left-wing extremists later claimed responsibility for the attack.

It was the fourth attempted attack against North Atlantic Treaty Organization or U.S. installations here in three months and followed a series of terrorist raids on alliance bases in Europe.

Police bomb squad officials said the shells were launched at 3 a.m. local time from terraced gardens that overlook the harbor on the River Tagus estuary here where six frigates of NATO's standing Atlantic force were docked. A shadowy extremist group, the Popular Forces of April 25, telephoned news agencies later to claim responsibility for the attack.

The attempted strike against the NATO vessels came after U.S. embassies in Europe were placed on special alert this weekend in anticipation of terrrorist attacks expected on official installations belonging to the alliance or member nations.

Urban guerrilla groups in Belgium, France and West Germany have carried out a number of recent raids on NATO targets in what investigators and U.S. officials believe to be a coordinated campaign.

On Friday, a French Defense Ministry official, Gen. Rene Audran, was slain outside his home in a Paris suburb in an attack claimed by the Direct Action terrorist group. The assassination has sparked fears of urban terrorism in France, which generally has been immune to such violence.

Capt. Eric Capela, a NATO spokesman, said the six ships had been in Lisbon since Wednesday preparing for maneuvers and set sail as scheduled six hours after the attack.

Navy officers said the shells were aimed at vessels from Britain, the Netherlands and Norway. the USS Richard E. Byrd with two frigates from Canada and West Germany were in an adjoining dock.

Police suspect that the shells fired were 60-mm mortar rounds identical to those used in similar attacks here last year. Three mortar shells landed in and around the U.S. Embassy grounds Nov. 25, causing slight damage and no injuries. Three weeks earlier the Popular Forces of April 25 said a makeshift rocket-launcher found near the embassy had failed to go off for technical reasons. The device was loaded with shells and equipped with a timing device. A similar raid on NATO's Iberian headquarters outside Lisbon Dec. 9 damaged a staff car.

The extremist group is named after the date of the 1974 "revolution of the carnations" that ended 48 years of right-wing dictatorship in Portugal. It has been held responsible for a series of bomb attacks, shootings and bank robberies since 1980 in which 12 persons have died. More than 50 suspected members of the group arrested in a nationwide police sweep last June are awaiting trial on terrorist charges.

Lt. Col. Otelo Saraiva de Carvalho, a military strategist of the almost bloodless coup in 1974 who became a leading symbol of Portugal's newly won political freedoms, has been formally indicted with "founding, leading and promoting" the extremist organization. He denies the charges, which are expected to come to trial this spring.

Justice Minister Rui Machete has said that documents and other evidence seized in the June crackdown indicate that the Popular Forces group has links with leftist terrorist organizations in Europe and elsewhere. But there has been no indication that the group's attacks on U.S. and NATO installations are linked directly to recent raids on alliance targets by Direct Action in France, the Fighting Communist Cells in Belgium and West Germany's Red Army Faction.