The twin sister of the shah of Iran, Princess Ashraf Pahlavi, escaped an assassination attempt early today by two hooded gunmen who fired on her Rolls-Royce along the French Riviera coast. But her lady-in-waiting was killed instantly and the driver was injured in the attack with semi-automatic pistols.

The 57-year-old princess was not hurt in the pre-dawn attack. police said it appeared to be a politically motivated act of terrorism by opponents of Shah Mohammed Reza Pahlavi's autocratic rule in Iran.

A spokesman for the princess, who was in seclusion at her third husband's sumptous villa in nearby Juan-les-Pins, said later, "She's absolutely, 100 per cent all right."

It was the eighth attack on a foreign diplomat or political personality in France in less than three years, fitting into what seems to be a pattern of increasing violent extremisim in Western Europe.

Princess Ashraf, who is five hours older than her brother, was riding home after an evening of gambling at the fashionable Palm Beach Casino in nearby Cannes when the gunemen stuck, police said.

Her lady-in-waiting, Kahainouri Forough, was sitting in the rear seat usually occupied by the princess and may have been mistaken for her, police said. She was killed by a single bullet in the head.

Police said a white Peugeot sedan, which the gunmen had stolen from a local car dealer, crowded in front of the Rolls-Royce and forced it to stop along a seaside road two miles from here.

Two assassins leaped out and fired semiautomatic pistols, blasting about 10 holes in the car, officers reported.

The pair jumped back in the car, reportedly driven by a third member of the gang, and sped away. The stolden vehicle was later found abandoned in Antibes, police said.

The driver of the Rolls-Royce, identified as Arus Ettemadian, 29, an Iranian businessman, was slightly wounded in the arm. Police said Ettemadian drove the princess, who was sitting in the car's treatment.

A fourth passenger, identified as Dijarchi Modergar of Iran, was sitting in the back seat of the Rolls-Royce and escaped injury.

Investigating officers said Ettemadian repeadly crashed the Rolls-Royce into the attack car during the shooting in an effort to get away.

There was no attempt at robbery and police said the gunmen were silent during the assault and left nothing to indicate their motives. But officers said they were presumed to be anti-shah terrorists. The Shah himself has been the target of several assassination attempts.

Several groups opposed to the Shah are active in France, and slogans demanding increased political freedon in Iran occasionally appear on Paris subway walls. An Iranian diplomat, Humayoune Keykavoussin, was wounded in Paris last summer. He later accused a dissident Iranian student of trying to kill him.

During 1976, at least 89 guerilla foes of the shah were executed or killed in gunfights with Iranian security forces.

Princess Ashraf is reputed to wield considerable political power.She is reportedly one of the few people the shah trusts.

She is said to possess enormous personal wealth. Critics of the royal family in Iran have charged that a great part of her fortune stems from payoffs by businessmen trying to operate in Iran.

An ardent advocate of women's rights, she gained publicity at the U.N. Women's Year Conference in Mexico City in 1975 when she donated $500,000 to the feminist cause.She has also been active in overseeing Iranian health and education programs.