By Joseph Ax

ELIZABETH, N.J. (Reuters) - The man accused of last month's bombings in New York and New Jersey that injured dozens of people pleaded not guilty on Thursday to charges of attempted murder stemming from his shootout with police.

Ahmad Khan Rahimi, whose last name had previously been widely reported as Rahami, appeared via video in a New Jersey state courtroom from his hospital bed, where he is recovering from gunshot wounds suffered during his arrest.

The 28-year-old was laying under a sheet as his court-appointed lawyer, Peter Liguori, stood beside his bed in hospital scrubs. He did not speak aside from answering "yes" to several questions from Union County Superior Court Judge Regina Caulfield about whether he understood the charges and wished Liguori to represent him.

Liguori told the judge that his client's last name was spelled "Rahimi."

The hearing in Elizabeth, New Jersey, lasted only a few minutes. Prosecutors said the state charges would be brought before a grand jury within a few months.

Rahimi, a U.S. citizen who was born in Afghanistan, is also facing federal terrorism charges in both New York and New Jersey. He is accused of setting off an explosive in Manhattan's Chelsea neighborhood that injured 31 people as well as a pipe bomb near a charity running race in a New Jersey shore town on Sept. 17.

In addition, Rahimi is charged with planting another pressure-cooker bomb in Chelsea that did not go off and with leaving several devices at a train station in Elizabeth. One of those explosives detonated when a bomb squad robot attempted to defuse it. None of the blasts killed anyone.

(Reporting by Joseph Ax; editing by James Dalgleish and Phil Berlowitz)