Rights groups locked out of court say Libya failing test of justice as Muammar Gaddafi's spy chief complains of access to lawyer

The war crimes trial of two of Muammar Gaddafi's sons and top officials descended into chaos in Tripoli on Monday, with neither son appearing and most observers barred from attending.

There were chaotic scenes outside the al-Hadba prison when guards told journalists that, despite assurances that the case billed as Libya's trial of the century would be open, there would be no public access.

After hasty discussions between officials and guards, the Guardian, al-Jazeera, Reuters and a handful of local journalists were allowed in, along with UN observers.

The courtroom, a low squat sand-coloured building inside a massive complex festooned with machine guns, armoured cars and black-uniformed armed police, had tight security. Journalists were told to surrender phones and even pens before entry, before being given ballpoint pens in return.

Inside, only 23 of the 39 defendants, representing most of Gaddafi's surviving elite, were present, sitting in two glum rows inside a black iron cage in light blue prison uniforms.

The front right position, nearest the judges, was occupied by Gaddafi's former intelligence chief and right-hand man, Abdullah al-Senussi. He looked lean and haggard, unrecognisable from the once-rugged figure accused of terrorising the population for three decades.

There was no sign of Saadi Gaddafi, 40, the late dictator's footballing son, and a video screen rigged up to show his older brother, Saif al-Islam, being held in the mountain town of Zintan, showed only an empty courtroom. The militia of Zintan have refused to surrender custody of Saif al-Islam to Tripoli, but judges were unsure why Zintan failed to produce him there.

Then came an announcement from the coastal city of Misrata that its militia wanted the same deal as Zintan, refusing to hand over seven defendants they are holding and demanding their own video link. Of the remaining eight accused there was no sign, with neither judges, prosecutor nor UN observers able to explain where they were.

The session took place with the country in crisis after the prime minister, Abdullah al-Thinni, resigned on Sunday, less than a month into the job, complaining that "cowardly" militiamen had attacked his family.

Senussi rose and told the court he had only just got a lawyer, six months after one was supposed to be appointed to prepare a defence against charges including murder, torture, kidnapping, false imprisonment, embezzlement and incitement to rape.

"I get treated completely differently to my fellow cellmates," he said in a shaky voice. "Five days ago I signed a paper with a defence lawyer."

Asked by judges for an explanation, the black-robed prosecutor Siddiq al-Sur said: "He was allowed visits, he was allowed to see his daughter, his cousins. We were looking for lawyers to defend him. We have asked him for the name of his lawyer."

Though Senussi, 64, and the other defendants, all male, looked thin and tired, none complained of torture or had signs of physical abuse. After an hour, judges adjourned the case until 27 April, ordering defence lawyers to be allowed to examine, but not take away with them, copies of the evidence against their clients.

"It's supposed to be an open session, but they are refusing to let me in," said a Human Rights Watch observer, Hanan Salah, who was barred entry by the guards.

"This is not a trial, they shouldn't call this a trial," said Ashraf Abdul-Wahab, chief reporter for the Libya Herald, standing by the prison gates. "This was a test for justice in Libya, and it's a test Libya failed."