PARIS, NOV. 29 -- In a bargain that won the release Friday of two French hostages, an Iranian official who had refused to leave his embassy here for six months submitted to brief interrogation about terrorist bombings tonight and flew out of France without being charged.

The testimony and immediate departure of the mysterious diplomatic official, Wahid Gordji, resolved the major problem in a long standoff between France and Iran and raised hope here that more hostages might be released soon.

Gordji, reported to be 27, had been holed up in the Iranian Embassy since early June, refusing to answer a summons on grounds of diplomatic immunity. He was sought for questioning by Judge Gilles Boulouque in connection with a wave of terrorist bombings last year in Paris that killed a dozen persons and wounded more than 150.

The French government announced that the agreement on Gordji's fate opened the way for the return of nine French diplomatic officials confined in Tehran since July, including a consul charged with espionage, and heralded an eventual renewal of diplomatic relations severed July 17.

The arrangement to allow a French investigating magistrate to hear Gordji was part of a complicated deal that began with the release Friday night of the two French hostages, Jean-Louis Normandin, 36, and Roger Auque, 31. Normandin, a television lighting engineer, and Auque, a free-lance reporter, arrived in France yesterday after being released in Beirut by the Revolutionary Justice Organization, a Lebanese-based group believed to have ties to Iran and Syria.

A communique from Prime Minister Jacques Chirac tonight said Iranian influence was essential in those releases and added that this influence "should permit the return to freedom of the other hostages still detained." Islamic Jihad, an operating arm of the Lebanese Hezbollah Party closely tied to Iran, has acknowledged holding the remaining French hostages.

Judge Boulouque heard Gordji for two hours at the Palace of Justice. At about the same time, a revolutionary Islamic court heard the French consul in Tehran, Paul Torri, on accusations of espionage and drug smuggling, according to the official Islamic Republic News Agency.

A communique here from State Prosecutor Michel Raynaud, Boulouque's superior, said no charges were brought against Gordji, "and as a result he left the Palace of Justice free."

According to law, the judiciary operates independently from the government. But there have been frequent reports of governmental attempts to influence decisions in the prosecutor's office, which is part of the Justice Ministry.

After a high-speed ride across Paris with a police escort, Gordji left in a special aircraft. A French Foreign Ministry official said later that Torri boarded a plane in Tehran after several hours of questioning.

News services reported that both men were headed for Karachi, Pakistan, where they would be exchanged. Earlier reports had said the exchange would take place in Cyprus.

The Iranian government had described Gordji as an embassy translator and said his diplomatic status exempted him from questioning by the French judge. But Chirac's government consistently insisted that the judge's summons must be obeyed under French law, contending that Gordji was a locally hired employe without diplomatic status who had maintained contacts with North African Islamic extremists accused of helping terrorists organize the bombings.

At the same time, reports attributed to French police described Gordji as a key Iranian intelligence operative in charge of promoting Moslem fundamentalist groups in France. Against that background, Chirac's government and President Francois Mitterrand were firm in insisting that Gordji must respond to the summons.

But when French police surrounded the Iranian Embassy here June 30 to prevent Gordji's departure, Iranian police surrounded the French Embassy in Tehran to prevent the departure of French diplomats. In addition, the Iranian court accused Torri, the French consul and first secretary in Tehran, of espionage and smuggling.

French officials refused to accept the charges, saying Iran was seeking to establish a false parallel and insisting that Torri had diplomatic immunity. The quarrel, which led to a rupture in relations, sidetracked Chirac's efforts to normalize relations with the Ayatollah Ruhollah Khomeini's Islamic government and enlist its good will in obtaining freedom for French hostages.

Before the dispute, five French hostages had been released between March and December last year. It was unclear whether the release of Normandin and Auque would be followed by liberation of the remaining three French hostages, but Chirac made it clear that this is France's demand in the agreement to renew relations.

Chirac said the agreement also concerns settlement of a longstanding dispute over a French debt to Iran, contracted before the shah was overthrown in 1979. The debt negotiations, his communique said, "should now see determinant developments." The newspaper Le Monde reported yesterday that France had paid a ransom. Chirac denied it.

Auque, speaking on French television today, said he was told by his captors that the Revolutionary Justice Organization also holds Briton Terry Waite, an emissary from the archbishop of Canterbury, and two Americans.

Auque told reporters here that he heard a man speaking with a British accent and saw through a hole in the wall last May a tall, bearded man fitting Waite's description. Although there have been reports of his death, the archbishop of Canterbury's office has maintained he is alive.

Auque also said a South Korean diplomat who was held hostage, Chae Sun, told him the two American hostages were suffering particularly severely in captivity. The two U.S. hostages held by the Revolutionary Justice Organization have been identified as Joseph Cicippio, kidnaped in September 1986, and Edward Tracy, kidnaped in October 1986. Chae Sun was kidnaped Jan. 31, 1986, and freed last Oct. 29.