PARIS (AP) _ Inmates at four French prisons refused to return to their cells Sunday to protest a presidential pardon granted to a convicted terrorist whose release was sought by Iran.

In some cases the prisoners demanded similar pardons.

In Tehran, where convicted terrorist Anis Naccache and his four accomplices flew after their release, a top Iranian official praised France's move as a ''humanitarian gesture.''

Naccache had served 10 years of a life sentence for the failed assassination of Shahpour Bakhtiar, Iran's prime minister before the 1979 Islamic revolution.

A policeman and a passer-by were killed and another policeman paralyzed in the 1980 assassination attempt in Paris.

Naccache was allegedly acting on Iranian orders and his imprisonment has been a major object of contention between France and Iran.

Mahmoud Vaezi, deputy Iranian foreign minister in charge of Euro-American affairs, told France's Ambassador to Iran, Christian Graffe, that the pardoning of Naccache would have a positive impact on Lebanese Moslem groups, Iran's Islamic Republic News Agency reported.

Sixteen Western hostages are held in Lebanon, mainly by pro-Iranian groups.

They include six Americans. The longest-held is Terry Anderson, chief Middle East correspondent for The Associated Press, who was kidnapped March 16, 1985.

In France, five employees of the Caen prison were slightly injured in incidents Saturday night sparked by the pardon, prison officials said. None was hospitalized.

Several hundred inmates at Ensisheim in eastern France, Loos-Les-Lille in the north, Baumettes in Marseille and Caen in Normandy all refused to return to their cells following the evening exercise period Saturday. Calm was restored by early Sunday morning.

In each case, officials said, the prisoners were protesting the pardon of Naccache and his accomplices.

Police took up positions around Ensisheim Prison, near Mulhouse, as up to 180 inmates spent five hours outside their cells.

At Loos-Les-Lille, about 150 inmates remained in the courtyard for an hour after exercise, demanding to be pardoned like Naccache.