A rape suspect stabbed his girlfriend’s 6-year-old daughter in the neck — and then stabbed the girlfriend when she tried to intervene in the attack in their Queens home, prosecutors said Friday.

Steven Bagu, 30, who was sought by cops in connection with the rape of his 11-year-old niece in Manhattan, was arraigned in Queens Criminal Court on charges that included attempted murder, assault, unlawful imprisonment and endangering the welfare of a child.

Bagu’s girlfriend awoke in her Kew Gardens Hills home shortly before 2 a.m. Thursday to the sound her daughter screaming, said Acting Queens DA John Ryan.

She ran into the living room and saw Bagu standing over the 6-year-old girl with a knife in his right hand. The little girl had been stabbed in the neck and was bleeding, according to court papers.

Bagu’s girlfriend tried to help her daughter — but the suspect blocked her, Ryan said.

Then the desperate mother turned toward the apartment door in hope of escaping and seeking help.

“That’s when the defendant allegedly jumped in front of her and grabbed her. The woman repeatedly tried to escape until Bagu allegedly stabbed her in the throat with the knife,” the Queens DA’s office said in a statement.

“For two hours, the defendant is alleged to have held both the woman and her daughter,” the statement said.

Eventually, Bagu fell asleep. As he dozed, his girlfriend fled to a neighbor’s apartment and called 911, said a criminal complaint.

Bagu was arrested at the scene.

The victims were taken to a hospital, where the girl received stitches to close a puncture wound to her neck. The mother had to undergo surgery to repair a punctured trachea.

Police sources said Bagu, of Brooklyn, was sought as a suspect in the rape of his 11-year-old niece earlier this month in Harlem.

”This was a heinous act of violence that put both victims at grave risk. The defendant is in custody and now faces spending decades in prison as punishment for his alleged criminal actions,” said Ryan.

NEW YORK TIMES DAILY