Two U.S. sailors were killed and 10 others wounded yesterday morning when terrorists ambushed a Navy school bus near a communications station west of San Juan.

Late in the day, three Puerto Rican pro-independence terrorist groups claimed responsiblity for the attack on the bus carrying 18 enlisted men and women to duty at a transmitter site.

President Carter deplored the attack as "a despicable act of murder" and said the Justice Department and the FBI would investigate.

Leaders of both pro-statehood and pro-independence factions on the island, a U.S. commonwealth, also dennounced the attack.

The navy identified the dead as John Robert Ball of Madison, Wis., a communications expert, and Emil E. White, a radioman from Charlotte Amalie, St. thomas, in the Virgin Islands. The names of the wounded were not released.

Of the injured, two were hospitalized in critical condition, five were in stable condition and three had been released after treatment.

In a communique found at a bus stop in San Juan, the three terrorist groups called the attack an act of retailiation for the death last month of one of their followers, an anti-Navy activist, and said that they are at war with "Yankee imperialists."

The ambush, the statement said, was "a miliatry attack against the naval intelligence base."

It identified the three groups as the Organization of Volunteers for the Puerto Rican Revolution, the Puerto Rican Popular Army and the Armed Forces of Popular Resistance.

Police said the yellow bus, which bore Navy markings, was sprayed with gunfire after it was blocked by a truck on a road bisecting the U.S. Naval Security Group Activity, a communications facility at Sabana Seca, 10 miles west of San Juan. Authorities counted more than 40 bullet holes in the bus.

The 18 sailors -- 14 enlisted men and four enlisted women -- were in uniform but apparently were unarmed. They were being driven to duty at a transmitter in the north sector of the Sabana Seca facility when they were ambushed about 6:42 a.m., minutes after they left the south sector where they live.

A truck overtook the bus on Puerto Rico highway 867 about a mile from Sabana Seca, according to the Fbi. The truck stopped, blocking the bus, and a number of armed men left the truck and started firing at the front of the bus.Ball, the driver, was killed immediately.

After the attack, the terrioists escaped in another vehicle, a van, according to police. It was found abondoned yesterday afternoon in Levittown, a San Juan suburb. Police said they found a dozen spent M16 shells inside the van.

According to Navy spokesmen, 300 military personnel are stationed at the Sabana Seca base, which is not open to civilians. The bus was on a routine shuttle run between the south and north sectors, which takes it off military property and onto a public highway.

Hours after the attack, an anonymous caller told United Press International in San Juan the location of the terrorists' communique.

The message said the attack was in retaliation for the death three weeks ago of Angel Rodriguez Cristobal in a Tallahassee, Fla., prison. Prison authorities said he hanged himself, but anti-Navy protesters in Puerto Rico claim he was killed in prison.

He was arrested during a protest of the Nacy's use of the island of Vieques, off eastern Puerto Rico, for target practice.

Rear Adm. Arthur K. Knoizen, the Navy's Caribbean commander, called yesterday's attack on the bus "an escalation of anti-Navy tactics."

"I feel the people of Puerto Rico will repudiate this outrage," he said.

Anti-Navy protesters have "escalated their cause from peaceful demostrations to criminal felony," he added.

The ambush was the first fatal attack on U.S. service personnel in Puerto Rico since 1970, when a serviceman was shot to death in what terrorists said was retaliation for the death of a student during a riot at the University of Puerto Rico in San Juan.

The political forces on Puerto Rico, a commonwealth of the United States, fall into three categories. The current government is pressing for statehood, while its major opposition comes from those who favor a rejuvenated version of the status quo. A minority of the population, never more than 6 percent in any election since 1952, wants independence.

Gov. Carlos Romero Barcelo called yesterday's attack "irrational and cowardly," while Ruben Berrios, president of the Puerto Rico e Independence Party, repudiated the act, saying it would only increase repression of dissent.