Cristopher Precopia, 21, was arrested on the morning of September 21, 2017 for allegedly attacking his girlfriend

A Texas man facing a 99-year prison sentence has been cleared of all wrongdoing thanks to a selfie.

Cristopher Precopia, 21, was arrested on the morning of September 21, 2017 and accused of breaking into his ex-girlfriend's Temple home, attacking her and carving an X into her chest with a box cutter.

The unnamed ex, whom he dated in high school several years earlier, claimed the attack happened the day prior, but Precopia knew he was out of town with his family at the time.

After his parents posted $150,000 bail, a selfie that his mother uploaded to Facebook with timestamp and location was the key piece of evidence to solidify his alibi.

'I had no idea why everything was happening, and I was lost,' Precopia told KVUE.

He faced a charge of burglary of a habitation with the intent to commit other crimes - a felony that carries a 99-year prison term.

The selfie that saved him: His mother had posted this group selfie to Facebook at the same time as the alleged attack that showed Precopia was 65 miles away

His unnamed ex-girlfriend claimed Precopia broke into her house, attacked her and carved an X into her chest with a box cutter (pictured) the night before he was arrested

The ex-girlfriend alleged the attack happened on around 7.30pm on September 20, 2017.

But Propecia said he was 65 miles away at a hotel in Northwest Austin with family.

His mother Erin, who says she's active on Facebook, realized she had posted group selfie right around the time of the attack occured.

The photo shows Precopia in the left corner while he and his mother are in the foreground and another couple is in the back.

'I'm thinking, ''this is awesome. By the grace of God, she said it happened on the day when I can say totally, 100 percent, where he was at,''' she told KVUE.

After spending thousands on lawyers fees, Precopia took his evidence to the Bell County prosecutor who dropped the charge 'in the interest of justice' nine months after his arrest.

Sworn affidavits from those with Precopia were also filed in his defense.

Nine months after his arrest, Precopia (left, with his mother) was cleared of all charges

'Most of the time, we deal with gray matters,' his attorney Rick Flores said. 'It's not normally black or white. But this is one of those cases where I could definitely prove he did not commit this offense.'

But the question remained. How was a person so obviously innocent and with a solid alibi arrested and charged?

In most cases, investigators attempt to interview a suspect before filing charges. But in this case, police reports show Precopia returned a phone call to police and left a message, which prompted his arrest.

The ex-girlfriend has not been charged with a crime, but told police that she and Precopia had a troubled relationship when they dated in high school, which she said was the motive for the alleged assault.

'I'm ready to actually live my life, the way I want to, without having any kind of worry that this can come back and hurt me,' he said.