A nephew of the deposed shah of Iran was assassinated yesterday by a lone gunman who shot him in the head outside his sister's apartment in a fashionable Paris neighborhood.

Prince Shahriar, 34, a former captain in the Iranian Navy and son of the shah's twin sister, Princess Ahsraf, thus became the first member of the former imperial family to be assassinated since the shah became a wanted man after the February revolution inspired by Ayatollah Ruhollah Khomeini.

In Iran, Ayatollah Sadegh Khalkhail, the self-proclaimed head of Iran's revolutionary tribunals, claimed responsibility for the murder, saying a member of his Fedayan-e-Islam guerrilla group carried it out.

Khalkhali earlier had made unsubstantiated assertions that he personally had dispatched an assassination squad to kill the shah in Mexico.

In Paris, an anonymous caller told the French news agency Agence France-Presse that the killing was the work of the Moslem Liberation Front, a previously unknown group. The caller concluded his message with the words, "Long live Khomeini."

In New York, an adviser to the shah, who is now hospitalized at Lackland Air Force Base in Texas, released a statement on behalf of the deposed monarch expressing deep grief over the murder. The shah eulogized his nephew as "a gallant naval officer" who "shunned any privileges of his position" and was "loved, respected and admired" by his men.

Associates of Shahriar Shafik described him as a quiet and unpretentious man who shied away from the alleged questionable financial dealings that enriched other members of the shah's family.

Iranian revolutionary authorities have said that the shah and several members of his family, including Princess Ashraf, have been sentenced to death in absentia, but Shafik's name was never mentioned in this connection.

According to French police, Shafik was shot at about 1 p.m. while walking down a street in Paris' 16th district near the home of his sister, Princess Azzadeh.

Princess Ashraf also maintains an apartment in the area.

Witnesses quoted by news agencies said the gunman, wearing a motorcycle helmet, walked up behind Shafik and shot him in the neck with an automatic pistol, then leaned over his body and fired a second shot into Shafik's head as he lay bleeding in the narrow, tree-lined street. The gunman calmly walked away from the scene and disappeared into the lunchtime crowds.

The assassin was said to be 25 to 30 years old, athletically built and of medium height.

Princess Ashraf was not in her nearby apartment at the time of the killing and was believed to be out of Paris.

Ashraf herself was the target of an assassination attempt in September 1977 when two hooded gunmen fired on her Rolls Royce as she was being driven along the French Riviera. Ashraf was not hurt in the predawn attack, but her lady-in-waiting was killed and her driver was injured.

Shafik was Ashraf's son by her second marriage to Ahmed Shafik, an Egyptian. Shafik's half-brother, Prince Shahram, was heavily involved in business dealings now being investigated by Iranian authorities. In October 1971, Shahram escaped a kidnap attempt in Tehran that was believed connected with his business activities.

Shafik reportedly was one of the last members of the shah's family to leave Iran during its revolutionary upheaval. A former commander of the shah's hovercraft fleet, he is said to have used one of the British-built craft to escape across the Persian Gulf after his uncle's monarch was overthrown.

According to sources in Paris, Shafik recently had been active on behalf of the shah's last prime minister, Shahpour Bakhtiar, who has vowed to return to Iran from his exile in Paris to lead the country to a secular democracy.

Shafik was married to the daughter of former Iranian prime minister Manouchehr Edhbal. His widow and two children are said to be living in the United States. CAPTION: Picture 1, Body of shah's nephew lies in a Paris street after he was slain by lone gunman; Picture 2, PRINCE SHAHRIAR SHAFIK . . . "gallantry" praised by shah, UPI