Not many illegal immigrants ask to be deported. But Jose Vallejo of Mexico did, rather than face a potential prison term of 30 years for sex assault here in the United States. And he nearly got his wish.

Prosecutors in Illinois say Vallejo, who is now a 17-year-old Mexican national, pinned a 4-year-old girl down on a bed, then molested her on April 12, 2006. Even though Vallejo was only 16 at the time of the alleged crime, he is being charged as an adult because of the age of the victim. He faces three counts, including aggravated criminal sexual assault, one count of unlawful restraint.

Originally, bond was set by a state judge at $150,000 but Vallejo's family posted the cash. So, Vallejo was released by the state, but soon after, was taken into custody by federal agents for illegally entering the country three years ago.

While in federal custody, Vallejo asked a federal immigration judge to deport him. The request was granted during a Jan. 4 deportation hearing in Chicago.

But before Vallejo was sent back over the border, federal Immigration and Customs Enforcement officials alerted prosecutors in McHenry County, Ill., and that agency took custody of him.

Click here to visit FOXNews.com's Immigration Center

"It's kind of terrifying to know that someone who has violated a four-year-old, sexually violated, would be washed from the system all of the sudden, he would escape from our country here and it'd be over," said state attorney Lou Bianchi.

Bianchi said a number of things could be added to courtrooms to give immigration judges tools to determine if someone before them has criminal charges pending, which could decide whether or not they stay in the United States to face charges.

"If they have a monitor, at least someone in the courtroom is watching the monitor and all of the sudden it would flash up on the screen that this man is wanted or he's got at least outstanding charges so that the appropriate authority like in this case," Bianchi said. "Our office could be notified so that we could take the proper precautions to make sure that these type of illegal aliens who commit crimes are not deported immediately so that we can prosecute them."

But Vallejo's attorney, Perry Grimaldi, argued in state court that the deportation order should stand, saying, "their law is supreme over the state laws. They are the ones that have taken him into custody. They are the ones that will conduct any further actions."

But a county judge on Jan. 16 ruled against Vallejo, upping his bond from $150,000 to $750,000 to prevent his deportation.

ICE characterizes this case as textbook, stressing that red flags were raised after the immigration judge's deportation order.

But immigration watchdogs say laws must be changed to ensure immigration judges are informed of pending criminal charges. Currently, these federal judges don't take criminal charges into account, unless that's the reason for the illegal immigrant's deportation hearing.

"The system should work in a way that the only people who go before an immigration judge who have committed some sort of crime has already served their time for that crime," said Jack Martin, special projects director for the Federation for American Immigration Reform. "In other words, they should not heave people coming before them that are involved in another judicial proceeding until that proceedings is completed."

Martin said the number of cases of this type is increasing with the illegal immigrant population in the United States; case loads of this type are growing by about 500,000 a year, and there are currently between 11 and 13 million — with some estimates saying as many as 20 million — people in the United States illegally.

Susan Eastwood, spokeswoman for the Justice Department's executive office for immigration review, told FOX News that immigration courts will not consider any crimes allegedly committed by an illegal immigrant, unless they are related to the immigration case at hand.

"Our judges do not take into account pending criminal charged against a defendant," Eastwood said. "The judges must stay fair and balanced on a case. A criminal case and a deportation hearing are separate trials. Immigration judges do not do criminal trials."

Now that he'll be in the United States for awhile, Vallejo has requested a jury trial. His next court date is scheduled for March 2.

FOX News' Jeff Goldblatt and Abby Silverman contributed to this report.