The Jerusalem District Court on Wednesday ruled that the prime suspect in the killing of Jerusalem teen Muhammad Abu Khdeir stay in custody until the end of legal proceedings against him.

Yosef Haim Ben-David, indicted for murder over the July 2 abduction and killing of Abu Khdeir, a 16-year-Shuafat resident, in an alleged revenge attack for the killing of three Israeli teens — Naftali Fraenkel, Gil-ad Shaar and Eyal Yifrach — on June 12, was committed to custody along with two other suspects in the case, both minors.

As opposed to Ben-David’s previous court hearing, which took place behind closed doors, the judge presiding over Wednesday’s hearing, Justice David Mintz, allowed Abu Khdeir’s relatives to attend.

The decision to hold an open hearing was contested by the defendants’ attorneys, who said any case involving minors — two of the three suspects in the case are under the age of 18 — must be heard behind closed doors. Mintz agreed to close the hearing, but only partially; while other members and supporters of Abu Khdeir’s family were eventually asked to leave the courtroom, his parents were allowed to stay in the room — and to see their son’s suspected killers for the first time.

The boy’s father, Hussein Abu Khdeir, disrupted the hearing by shouting “dog” and “Nazi” at one of the defendants as he was being led into the courtroom.

He also repeated a demand that the government demolish the homes of the suspects’ families, as it has done to the houses of many Palestinians accused of killing Israelis.

“I’ve come to see the Nazis who burned my son, why don’t they destroy their houses, too?” said Abu Khdeir.

Meanwhile, outside the courthouse, dozens of East Jerusalem residents held a protest calling for justice for Abu Khdeir’s family.

The family of Muhammed Abu Khdeir is seen outside the Jerusalem District after a court hearing against the 16-year-old youth's suspected killer. (photo credit: Yonatan Sindel/Flash90)

The family of Muhammed Abu Khdeir is seen outside the Jerusalem District after a court hearing against the 16-year-old youth’s suspected killer. (photo credit: Yonatan Sindel/Flash90)

Last week, Ben-David’s indictment was read. Ben-David’s lawyer, Aharon Roza, said that the statement shows that the suspect was in deep mental distress, and asked for Ben-David to be examined by a court-appointed psychiatrist.

The defendant is expended to plead temporary insanity.

According to Channel 2, Roza said during the hearing, “I met the client in severe mental distress, and he spoke disconnectedly about all sorts of messianic things, and about demons who tell him what to do.

“He is disconnected from reality at this stage, and says he is the messiah, son of David, which matches his name.”

Ben-David, 29, is a resident of the West Bank settlement of Adam and owns an eyewear store in Jerusalem. His detention has been extended until the end of his legal proceedings.

Ben-David is one of three suspects indicted on July 17 for the crime. Two of the defendants were also charged with the attempted kidnapping of a seven-year-old Palestinian boy in Beit Hanina the night before the killing, attempted arson, and the torching of a Palestinian store in the West Bank village of Hizme in June.

The indictment said that the three suspects went on “a human hunt,” during which they “cruelly kidnapped and murdered the minor Muhammed Abu Khdeir simply for being an Arab.”

Attorney General Yehuda Weinstein strongly condemned the “grave and shocking” crime, which was “carried out against an innocent youth on racist grounds,” and “opposes basic human morality.”

The other two suspects are 16 years old — one from Jerusalem, the other from Beit Shemesh. According to the indictment, Ben-David and one of the minors have a history of mental illness and are presently on medication. The two minors have not been named.

Immediately after the killing, the suspects said, they went to the older defendant’s home, where they “played guitar and went to sleep.”

Arab protesters hold placards during a demonstration in support of the family of slain East Jerusalem teen Muhammed Abu Khdeir outside the Jerusalem District Court, Wednesday, August 6, 2014. (photo credit: Yonatan Sindel/Flash90)

Arab protesters hold placards during a demonstration in support of the family of slain East Jerusalem teen Muhammed Abu Khdeir outside the Jerusalem District Court, Wednesday, August 6, 2014. (photo credit: Yonatan Sindel/Flash90)

The three have confessed to the killing; they reenacted it in the police interrogation. They said it was meant to avenge the killing of the the three Israeli teens, who were laid to rest a day before the killing of Abu Khdeir.

They said that following the discovery of the three bodies on June 30, after an 18-day hunt, two of the defendants plotted to harm Arabs in retaliation. The night the bodies were found, they attempted to snatch the 7-year-old Beit Hanina child, but were fought off by the boy’s mother.

The next night, with the third defendant in tow, they drove around again to find a victim and abducted Abu Khdeir.

The indictment stated that the three, who were raised in Orthodox families, changed their clothes to look like secular Israelis, filled bottles with gasoline, and brought along handcuffs.

While scouting out potential victims, they spoke with various children, but decided not to abduct them and briefly considered kidnapping an adult. The three then saw Abu Khdeir sitting on the side of the road, and approached him to determine if he was Palestinian. They asked him for directions to Tel Aviv and Damascus Gate, and he began to respond before growing suspicious and attempting to call his friends for help. The defendants then grabbed the struggling teenager, pushed him into the car, and beat him with a tire iron.

Upon reaching the forest, the adult suspect shouted: “This is for the Fogel family!” “This is for Shalhevet Pass!” in reference to previous Israeli terror victims, while striking Abu Khdeir. He then allegedly hit him three more times for the slain Israeli teenagers before setting him on fire.

The killing of Abu Khdeir sparked riots among Israel’s Arab population throughout the country, and drew fierce domestic and international condemnation. Seven suspects were initially arrested, but four were released days later.

Lazar Berman and Marissa Newman contributed to this report.