A man accused of raping and killing his 11-year-old neighbor told investigators that he thought the little girl was an intruder and that he did not remember having sex with her.

Andreas Erazo’s confession was videotaped after he was arrested in the July 12 slaying of Abbiegail “Abbie” Smith in their Keansburg apartment building.

The tape was played in court last week as part of hearing to determine whether it will be shown to a jury, according to the Asbury Park Press, which covered the proceeding.

Erazo, now 19, said he swung his knife at a figure in his apartment thinking that it was an intruder.

He then realized he had stabbed Abbie, describing her as looking “like a fish out of water.”

He also claims that he does not remember raping the girl.

“I blacked out. I don’t remember everything that happened that night,” the Press quoted him as saying in the video.

Erazo has pleaded not guilty to first-degree murder, three counts of aggravated sexual assault and several weapons offenses.

Erazo’s attorney has challenged the video and the confession, saying it was obtained without an attorney present and after several hours of being grilled.

Erazo told investigators that he had not been taking his medications and described a troubled upbringing. At the time of his arrest, Erazo was on probation for a juvenile offense.

Authorities found Abbie’s almost-naked body tied up with a computer cord and wrapped in a blanket on the roof of the Hancock Arms Apartments on the morning after her mother reported her missing. Authorities say she was stabbed in the neck and Monmouth County Prosecutors Christopher Gramiccioni called it one of the worst crimes he had ever seen.

At an earlier hearing to determine whether Erazo would remain behind bars as the case proceeds to trial, Public Defender Courtney Schneider noted that Erazo did not admit to “a knowing or purposeful murder, which are the necessary elements of this offense that the state must prove beyond a reasonable doubt.”