(CNN) -- An appellate court on Thursday ordered a new trial for a Florida woman who was sentenced to 20 years in prison for firing a gun to scare off her allegedly abusive husband, ruling that a jury was improperly instructed on self-defense.
Marissa Alexander's case will be retried because the jury was wrongly told that -- for her to claim self-defense -- she needed to prove beyond a reasonable doubt that her husband was about to seriously harm her, the appellate court said.
Rather, the appellate court pointed out, the prosecution had the burden to prove that Alexander herself was guilty of aggravated assault.
"Because the jury instructions on self-defense were fundamental error, we reverse" the conviction, a three-judge appellate panel said.
A jury convicted Alexander, 31, of aggravated assault in March 2012 after just 12 minutes of deliberation.
Alexander's lawyer said he told her about the new trial by phone.
"Marissa was ecstatic and obviously she's incredibly thankful and wants to get back with her family," defense attorney Bruce Zimet told CNN.
The case gained the attention of civil rights leaders, who say the African-American mother of three was persecuted because of her race, and from others, including U.S. Rep. Corrine Brown, who said the sentence was too harsh and Alexander never should have been charged.
Alexander claimed self-defense, saying she was attempting to flee her husband, Rico Gray, on August 1, 2010, when she picked up a handgun and fired a shot into a wall.
She said her husband had read cell phone text messages that she had written to her ex-husband, got angry and tried to strangle her.
State Attorney Angela Corey had said the case deserved to be prosecuted because Alexander fired in the direction of a room where two children were standing.
Corey had said she offered Alexander a plea bargain that would have resulted in a three-year prison sentence, but Alexander chose to take the case to a jury trial, where a conviction would carry a mandatory sentence under a Florida law known as "10-20-life."
The law mandates increased penalties for some felonies, including aggravated assault, in which a gun is carried or used.
During sentencing in May 2012, a judge said he had no choice but to sentence her to 20 years.
"Under the state's 10-20-life law, a conviction for aggravated assault where a firearm has been discharged carries a minimum and maximum sentence of 20 years without regarding to any extenuating or mitigating circumstances that may be present, such as those in this case," Judge James Daniel said that year.
Before the trial, Alexander unsuccessfully tried to use Florida's Stand Your Ground law to argue she was immune from prosecution. To win the immunity hearing, she would have needed to show that she was more likely entitled than not to use force.
But a judge in the pretrial immunity hearing rejected the request, saying Alexander's decision to go back into the house was not consistent with someone in fear for her safety.
In Thursday's decision, the appellate court said Alexander would not get a new immunity hearing. But she can still claim self-defense at trial.
The office of the Florida state attorney for Duval County said Thursday that Alexander's conviction "was reversed on a legal technicality."
"We are gratified that the court affirmed the defendant's Stand Your Ground ruling" denying pretrial immunity, the office said.
InSession's Jessica Thill and CNN's Chuck Hadad, Michael Pearson and Marylynn Ryan contributed to this report.