Jason Allen Alexander attempted to go into the singer's bedroom as she prepared to marry Sam Asghari in June.

Who knew that "leave Britney alone" would turn out to be very sound legal advice?

Britney Spears' former husband has been convicted of aggravated trespassing and battery after he attempted to crash the singer's wedding in June.

Jason Allen Alexander, whose marriage to Spears lasted 55 hours following a 2004 Las Vegas ceremony, pleaded no contest to the misdemeanor charges on Friday, the Associated Press reports.

A Ventura County, Calif., judge sentenced Alexander to the 64 days he'd already served in jail, and prosecutors dropped a felony stalking charge and a misdemeanor vandalism charge that he'd also been facing.

BEVERLY HILLS, CA - APRIL 12: Honoree Britney Spears attends the 29th Annual GLAAD Media Awards at The Beverly Hilton Hotel on April 12, 2018 in Beverly Hills, California. (Photo by Alberto E. Rodriguez/Getty Images)
Britney Spears
| Credit: Alberto E. Rodriguez/Getty

Alexander, 40, tried to enter Spears' locked bedroom in her home in Thousand Oaks, Calif., as the pop star prepared to marry Sam Asghari on June 9, according to the singer's security guard.

Alexander livestreamed his actions on Instagram and insisted over and over that he be allowed to speak to Spears.

"She's my first wife, my only wife. I'm her first husband. I'm here to crash the wedding," Alexander said in the video, captured by TMZ.

A sheriff's deputy testified that he found a "Gerber folding box cutter" in Alexander's possession.

Spears' attorney, Mathew Rosengart, previously told EW he would be "aggressively pursuing all appropriate charges" against Alexander.

Spears' wedding to Asghari did move forward, and they tied the knot in front of a crowd that included Madonna, Drew Barrymore, and Selena Gomez.

Asghari is Spears' third husband. After her brief marriage to Alexander she went on to wed Kevin Federline later in 2004. The couple, who split in 2007, have two children: Sean Preston, 16, and Jayden, 15.

Federline, 44, recently made news when he told The Daily Mail that Spears' children "decided they are not seeing her right now," in part because of the racy photos she posts on Instagram. "It's been a few months since they've seen her," he said.

Asghari responded with an Instagram story that denied Federline's claims. "It is irresponsible to make that statement publicly," Asghari said in an Instagram Story, as captured by PEOPLE. "The boys are very smart and will be 18 soon to make their own decisions, and may eventually realize the 'tough' part was having a father who hasn't worked much in over 15 years as a role model."

Spears posted her own Instagram Story about Federline's statements, saying, "As we all know, raising teenage boys is never easy for anyone. It concerns me the reason is based on my Instagram. It was LONG before Instagram. I gave them everything. Only one word: HURTFUL."

Representatives for Spears did not immediately respond to EW's request for a comment on Alexander's conviction.

Sign up for Entertainment Weekly's free daily newsletter to get breaking TV news, exclusive first looks, recaps, reviews, interviews with your favorite stars, and more.

Related content: