NANTES, France (AP) _ The three gunmen who seized a courtroom during a robbery trial surrendered unconditionally and released their final two hostages unharmed at Nantes airport today, police said.

A car carrying the three gunmen, who were in handcuffs, pulled up outside the Nantes airport terminal and the two hostages, escorted by police, entered a police command post in the terminal.

A pro-Palestinian man who burst into the crowded courtroom Thursday morning with guns and grenades and two defendants in the trial left the courthouse earlier today and sped off in a police-supplied car to the airport. The three spent several hours on a runway surrounded by dozens of police officers and vehicles.

The three gunmen were in police custody.

One of the hostages, Assistant Judge Bernard Bureau, said the gunmen had been ''very determined. I was extremely afraid ... The most difficult moment was when we came out of the courthouse.''

He said there were long periods when the gunmen held grenades with the pins out in their hands. Bureau said he believed the man who stormed the courtroom, identified as Abdel Karim Khalki, ''acted out of deep friendship'' for the two other men.

He said that ''at the beginning it was a suicide operation for them'' but the gunmen later ''wanted to limit the price.''

Bureau was smiling, but displayed a lump on the head and explained he had been struck by one of the gunmen during the ordeal.

Jean Chevance, the region's local governor, earlier told reporters the gunmen talked of going to Morocco or Switzerland and said negotiations could talk days.

Dominique Bailhache, the presiding judge in the trial who had been handcuffed to the gang's leader, also was one of the last hostages released.

The gunmen had threatened to kill the hostages unless they were allowed to go free.

The gunmen left the courthouse about 30 minutes after gang leader Georges Courtois, one of the trial defendants, appeared on the courthouse steps handcuffed to the judge and fired several shots from behind a column, apparently in the direction of a crowd of reporters and police 70 yards away.

Witnesses said Courtois was armed with a grenade in one hand and a large- caliber pistol in the other. A television camera lens exploded when it was hit by one of the bullets.

Courtois, still handcuffed to Bailhache, later met with a police officer who reportedly issued instructions by radio for police not to intervene when the gunmen left the courthouse.

The other two gunmen followed, one accompanied by two hostages and the third with the fourth hostage. It was not clear if the other hostages were handcuffed to their captors.

The gunmen originally held about 35 people captive, but by the time they left the courthouse all but four had been released.

They released nine of the hostages this morning and threatened to kill themselves and the four remaining hostages if they could not escape. The Nantes courthouse was ringed by heavily armed police commandos.

Earlier, a source reported that the gunmen had attempted to flee the building while they still held 13 people captive, but lost heart and turned back when they reached the darkened lobby. There was no immediate official confirmation.

A radio reporter, Joel Bitoun, visited the gunmen and identified those still captive as three judges and a prosecutor. Courtois had demanded to see a journalist.

Bitoun, who came out just before noon, said Courtois told him, ''either he gets out or he commits suicide and takes the hostages with him.''

The reporter quoted the gunman as saying: ''I am not afraid of death.''

Bitoun said that just before he left, each of the three gunmen took out a hand grenade, pulled the pin and held it in his hand.

On Thursday, Courtois warned in a nationally televised broadcast that ''the slightest attempt by police to intervene will be immediately met with a response in the seconds that follow.''

Michel Chauty, mayor of the city about 300 miles southwest of Paris, visited the courthouse at 9:30 a.m.

French Police Superintendent Robert Broussard was among the negotiators seeking to avoid bloodshed.

The drama began Thursday, when a man claiming to be a member of a group expelled from Yasser Arafat's PLO Fatah faction burst into a courtroom where four people were on trial for armed robbery, criminal association and possession of stolen goods.

Khalki, identified by police as a convicted armed robber from Morocco, brandished a grenade and a pistol. He disarmed a guard at the entryway, ran up to the judge and seized him by the throat.

Two of the four defendants then leaped from the dock and joined the intruder, grabbing 357-caliber Magnums from police, sources said.

The gunmen threatened to kill the hostages, haranged the French legal system on live television, and chained Bailhache to his chair.

Police identified the defendant who joined Khalki, 30, and Courtois, 34, as Patrick Thiolet, 24. The two other defendants fled the courtroom when the siege got under way, they said.

Five gunshots went off in the courtroom in the course of the day Thursday, but police said no one was hit.

Khalki said he was a member of a Palestinian group headed by Abu Nidal, and showed reporters what he said were photographs of fighting in Lebanon. The group led by Nidal, who was expelled from the Fatah faction of the Palestine Liberation Organization, has claimed responsibility for dozens of attacks in Europe and the Middle East.

Among those freed by the gunmen were six police officers, 11 law students observing the trial, two journalists and two jurors, a man with heart trouble and a woman who is diabetic, said a TV cameraman who had been inside the courtroom.

22EST