A man believed to be a member of the MS-13 gang allegedly broke into the room of an 11-year-old girl and raped her in her Brooklyn bed, according to local police.

Julio Cesar Ayala, 18, was detained by the NYPD on Saturday and charged with sexually motivated burglary and first-degree rape.

On Wednesday at 11.30pm, the El Salvadoran immigrant allegedly climbed onto the roof of the girl's apartment building Prospect-Lefferts Gardens.

Julio Cesar Ayala, 18, was detained by the NYPD on Saturday and charged with sexually motivated burglary and first-degree rape

On Wednesday at 11.30pm, the El Salvadoran immigrant allegedly climbed into the girl's room and raped her

Ayala is said to have then climbed through the girl's window on the second floor, squeezing through a narrow gap next to an air conditioning unit, the New York Post reports.

Police used surveillance video to get an idea of his identity

He then raped the girl in her bed, speeding back out the window when she began screaming for her mother.

The mother called police but did not see Ayala. There was video-surveillance in the area that indicated that Ayala was the suspect, however.

The girl was taken to a local hospital but is said to be in a stable condition, according to NBC New York.

Officers from the NYPD's Emergency Service Unit and the 70th Precinct raided the man's hideaway at an under-construction building at 930 Flatbush Avenue.

Ayala - who has a Green card - was seen pulled from the address wearing a red T-shirt and dirty black jeans.

Folks in the area cheered as the suspect was taken away in a squad car.

Ayala has no previous record but a high-level police source believed that he could be a member of the MS-13 gang.

'That makes me feel unsafe in my own home,' said Elizabeth Bardourilla, 42, a mental-health counselor and resident in the area where the girl lives.

'That child can't help herself. For a grown man to do that. Sick. Very sick. This is sad. Just sad.'