The man suspected of terrorizing New York and New Jersey with a series of bombings last month appeared in court here for the first time Thursday via a video feed from a hospital, where he continues to recover from wounds he suffered in a shootout with police.

Ahmad Khan Rahimi, 28, a U.S. citizen who was born in Afghanistan, lay in a medical bed, his arms covered with a blanket and his head propped up with a pillow, as Judge Regina Caulfield read the state charges against him. He answered “yes” — his voice barely audible in the courtroom — as Caulfield asked him whether he understood that he had legal representation and that his bail had been set at $5.2 million.

Defense attorney Peter Liguori stood next to Rahimi, yellow medical garb covering his regular clothes.

The hearing lasted just minutes. Liguori asked that the court note his client’s last name is spelled “Rahimi,” and not “Rahami,” as had been widely reported.

Ahmad Khan Rahimi. (Union County Prosecutor’s Office via Associated Press)

Prosecutor Ann Luvera said the matter would be presented to a grand jury in the next few months.

Rahimi is facing state and federal charges in connection with what authorities have alleged was a terrorism spree that seemed to be inspired by an eclectic mix of radical Islamic influences. He is suspected of a bombing that injured dozens in the Chelsea neighborhood of Manhattan and three other blasts in New York and New Jersey that did not hurt anyone.

In one of those instances, a bomb exploded along a planned race route in Seaside Park, N.J., but no runners were passing because the race had been delayed. In another, authorities were tipped to a possible explosive device at a train station in Elizabeth and inadvertently set it off while trying to disarm it.

Soon after the incidents, federal and local law enforcement officers began a widespread manhunt for Rahimi, who had been caught on surveillance video and who left fingerprints on a fourth device, an unexploded bomb found in Manhattan. He was taken into custody Sept. 19 in Linden, N.J., after a shootout with police that left him seriously wounded.

Rahimi had not been able to appear in court earlier because of his injuries, and one of his attorneys said he has still not been served with federal charges, which include using weapons of mass destruction and bombing a public place.

In Union County, N.J., he is charged with attempted murder and related weapons counts stemming from his shootout with police.

Alexander Shalom of the American Civil Liberties Union of New Jersey, who is representing Rahimi in the federal case, said the hearing in state court “doesn’t necessarily trigger any movement on the federal case.” He said it is unclear when Rahimi will be able to leave the hospital and face those charges.

In a journal recovered after his capture, Rahimi had written about his hopes for martyrdom and referred to former leaders in both al-Qaeda and the Islamic State, authorities have said.

“Inshallah,” he wrote, using an Arabic term for “God willing,” “the sounds of the bombs will be heard in the streets,” according to federal prosecutors.

Authorities have been scrutinizing Rahimi’s foreign travels and his previous contacts with law enforcement. The FBI had opened an inquiry of Rahimi in 2014 after his father called the FBI and said his son was a terrorist. His father later recanted his statement, and the FBI found no evidence of terrorist connections.

Rahimi traveled to Pakistan in 2013 and 2014, including stays in Quetta, a stronghold of militant groups, and Customs and Border Protection officials flagged him for questioning at least twice, law enforcement officials have said. But authorities found no reason to accuse him of any wrongdoing, officials have said.