Sushila Bishnoi, 19, appealed to a court to dissolve her underage marriage. But her husband denied the couple were ever betrothed, threatening to scuttle her case.
The teenager, aided by an activist, trawled her husband's Facebook accounts until they found the smoking gun that proved their marriage occurred when she was underage.
"Many of his friends had posted congratulatory messages on his Facebook page," said Kriti Bharti, an activist whose Sarathi Trust charity has annulled many child marriages in Rajasthan.
"The court accepted the evidence and declared the marriage invalid," she said of the ruling on Monday.
The couple were married at a secret wedding ceremony in Barmer district in 2010 when both were just 12 years old.
Ms Bishnoi said her parents were forcing her to move to her husband's house and consummate the marriage.
"I wanted to study but my family and my in-laws wanted me to live with a drunkard," she told news agency AFP. "It was about life and death, and I chose to live."
She ran away from home to a shelter where she met Ms Bharti, who helped her begin legal proceedings to dissolve the union.
This week, the Supreme Court declared sex with a minor akin to rape even if the couple was married, a landmark ruling that closed a legal loophole around child marriage.
Get the latest election news, live updates and election schedule for Lok Sabha Elections 2019 on ndtv.com/elections. Like us on Facebook or follow us on Twitter and Instagram for updates from each of the 543 parliamentary seats for the 2019 Indian general elections.