Police remove Michael Sandford as Republican presidential candidate Donald Trump speaks at the Treasure Island hotel and casino in Las Vegas on June 18, 2016. (John Locher/AP)

When Michael Steven Sandford drove from southern California to Las Vegas in June, he allegedly told investigators he had two goals in mind.

The first: Learn how to fire a gun.

The second: Kill Donald Trump.

Sandford, a 20-year-old Briton, had never used a gun in his life, according to court documents. So on June 17 he went to the Battlefield Vegas gun range, just a few miles off the Las Vegas Strip, and unloaded 20 rounds from a rented Glock 9mm at a paper target.

The next day, Trump held a political rally in the Mystere Theater at the Treasure Island Casino. Sandford, unarmed, passed through the metal detectors to watch the Republican nominee speak. As Trump addressed the crowd, Sandford approached a Las Vegas police officer, asking if he could get the candidate’s autograph. Then, without warning, he reached for the officer’s gun with both hands.

Security stopped him before he could unholster the weapon. “We love our police,” Trump said as Sandford was carried out of the casino in handcuffs.

Sandford was initially charged with an act of violence on restricted grounds, but he was later indicted on firearm and disruption charges.

On Tuesday, Sandford pleaded guilty to one count of being an illegal alien in possession of a firearm and one count of disrupting an official function, both felonies. Prosecutors have recommended a sentence of 18 months to two years. Although court papers show he admitted to special agents that he wanted to kill Trump, his plea leaves out talk of an assassination plot.

“It is fortunate that no one was harmed in this incident,” U.S. Attorney Daniel Bogden said in a statement. “The Las Vegas Metropolitan Police Department officer’s attentiveness and quick action prevented the escalation of this crime. The result was that no one was injured.”

The plea agreement in Nevada federal court recounts the bizarre details leading up to Sandford’s crimes, but differs from the initial criminal complaint in that it stops short of stating that Sandford wanted to shoot Trump. Instead, Sandford, who had overstayed a tourist visa by nearly a year, confessed to seizing the officer’s gun and interfering with Trump’s speech.

The Sandford family attorney, Saimo Chahal, told the Associated Press that Sandford was delusional when he went to the rally, and family members have said he suffers from a range of mental health issues, including autism. In his sentencing hearing Tuesday, Sandford told the judge that he was taking a medication used to treat bipolar disorder, according to the Las Vegas Review Journal.

“I was very relieved that he signed it,” Sandford’s mother, Lynne Sandford, told the Mirror. “It was a bit of a battle because he is quite headstrong. But we all laid the options out there for him on the table and, of course, it is a gamble.”

Sandford could have faced 10 years in prison and a $250,000 fine for each offense, according to the plea agreement. He acknowledged in the document that “it is almost certain” that he’ll be deported from the United States with “no possibility of returning.”

The Trump campaign has been mum on the attempt. Even as the scene unfolded in the casino, it was unclear whether the candidate even realized what was happening.

Sandford’s father, Paul Davey, said at the time of his son’s arrest that he believed he was “blackmailed or put up to it.”

Davey said Sandford had met a woman and moved to the United States to be with her. Court papers show his tourist visa expired in August 2015.

“He’s a nice kid and literally wouldn’t hurt a fly,” Davey told the Britain-based Portsmouth News in June. “He used to tell us not to use fly spray because he didn’t want any flies to die.”