The British national who attempted to steal a police officer’s gun in an effort to kill Donald Trump at a Las Vegas rally this past June pleaded guilty Tuesday to two charges tied to the incident.  

Michael Steven Sandford, 20, entered the pleas to being an illegal alien in possession of a firearm and disrupting an official function.

"I tried to take a gun from a policeman to shoot someone with, and I'm pleading guilty," Sandford told the judge.

Sandford, who was in the U.S. illegally after overstaying his visa, could have faced up to 20 years in a U.S. prison if he had been convicted at trial of both charges.

However, sentencing guidelines call for 18 to 27 months in prison for the offenses after credit for time served, accepting responsibility for the crime and avoiding trial, which had been set to start Oct. 3. Under the plea deal, Sandford won't be able to appeal.

Sentencing is set for Dec. 13.

Sandford, 20, was arrested June 18 after grabbing for the gun in a 1.500-seat venue at Treasure Island hotel-casino. Sandford didn't get the gun, and no shots were fired before he was arrested.

Sanford entered his pleas after his mother, Lynne Sandford, and a lawyer arrived from London and met with him in custody last week.

Family attorney Saimo Chahal said a psychiatrist she enlisted to review the case determined that Sandford was delusional at the time of the attempted attack. Sandford also suffers seizures, obsession-compulsion, anxiety and autism spectrum disorders, Chahal said.

"Michael was not in control at the time of the events and needs help," the attorney said in an email to The Associated Press before the plea in U.S. District Court in Las Vegas. "He is desperate to return to the U.K. to be near his family as he has no ties with the U.S.A."

Court documents say Sandford acknowledged asking the police officer at the event if he could get Trump's autograph then grabbing with both hands for the officer's 9mm handgun.

It wasn't clear if Trump recognized a threat before officers escorted Sandford out of the auditorium.

Sandford later told a federal agent that he drove from California to Las Vegas with a plan to kill Trump, and that he rented a 9mm pistol and fired 20 shots at a paper target at a Las Vegas gun range the day before Trump's appearance, according to court documents.

Sandford told the agent it was the first time he had ever fired a gun.

He also said he expected he would be killed during the assassination attempt, but that if he wasn't, he would make another attempt on Trump's life at a rally in Phoenix, court documents state.

The plea agreement acknowledges Sandford had been in the U.S. illegally for almost 10 months at the time of his arrest.

As a result of his plea, "It is almost certain that he will be permanently removed ... and will not be able to return to the United States at any time in the future," the document said.

Fox News' Matt Dean and the Associated Press contributed to this report.