An illegal immigrant is one of two teens arrested in Maryland in connection with the brutal kidnapping and rape of a young woman -- allegedly on orders of another female, officials said.

Frederick police said Salvadoran citizen Victor Gonzalez-Gutierres, 19, and Edgar Chicas-Hernandez, 17, were taken into custody last week. A third suspect is not in custody.

The 18-year-old victim was ambushed by three men as she walked to her apartment around 12:30 a.m. on Sept. 2, police said. The suspects cut the woman with a knife, hit her, pulled her hair and dragged her into a vehicle, FOX5DC reported.

NEW JERSEY DETECTIVE FATHERS CHILD WITH 15-YEAR-OLD, IS CHARGED WITH SEXUAL ASSAULT OF MINOR

The woman told police that Chicas-Hernandez and Gonzalez-Gutierres – who she said were known to be involved in gangs – held her captive and raped her for several hours. The third suspect reportedly filmed the crime.

The three men then allegedly took her back to her apartment complex. Before releasing her, they warned her “next time it will be worse” if she reported the incident, police said.

The 18-year-old told police the third suspect had his face covered and she could not recognize his voice, the Frederick News Post reported, citing court documents.

“We’re looking into all possible gang affiliations and ties to see if the suspects have or had any ties to local gangs or transnational gangs,” Frederick Sgt. Andrew Alcorn told FOX5DC. “This is not a common occurrence in Frederick. It’s a very quiet town and we like to keep it that way, and when an incident like this occurs we put all our available resources into solving it.”

The victim told police the three men told her they were following orders from a younger female acquaintance.

ARKANSAS HIGH SCHOOL TEACHER, 25, SLEPT WITH 4 TEEN BOY STUDENTS, 2 IN SAME NIGHT, COPS SAY

Investigators reportedly obtained copies of social media conversations in which a younger girl offered to give other acquaintances footage of the assault in exchange for “[one] night of pleasure,” the Frederick News Post reported.

Police said they also learned the younger girl had identified herself during the conversation and had even contacted one of the acquaintances before the assault, outlining her plan to extort money from the older girl.

According to the Frederick News Post, police questioned the younger girl about her potential role in the crime. She reportedly admitted that Chicas-Hernandez and Gonzalez-Guttierres would likely tell investigators she ordered them to commit the assault.

The younger girl reportedly denied any involvement in the crime, court documents said.

Chicas-Hernandez was arrested Sept. 12 and is charged as an adult because of the gravity of the crime. Gonzalez-Guittierres was taken into custody the following day.

Both men were charged with kidnapping, first-degree rape, sodomy, and first- and second-degree assault.

U.S. Immigration and Customs Enforcement lodged an immigration detainer for Gonzalez-Gutierres. In a statement, ICE said the teenager was released on immigration bond April 27.

“These detainers serve as a legally-authorized request...to maintain custody of an alien for up to 48 hours so that ICE may assume custody for removal purposes,” the statement said, the Daily Mail reported.

It’s unclear how long Gonzalez-Gutierres has been in the U.S.