A Mexican man and woman jailed for sending online messages that mistakenly warned an elementary school was under attack were freed on Wednesday, an attorney for the pair said.

Gilberto Martinez, a math teacher, and Maria de Jesus Bravo, a local radio host, walked out of jail on Wednesday afternoon, said their lawyer Fidel Ordonez.

The pair had been behind bars for more than three weeks after using their Twitter accounts to say that gunmen had targeted a school in the city of Veracruz one afternoon in late August.

The two faced charges that equated spreading word of a violent attack with terrorism under laws in their native Veracruz, a state on the Gulf of Mexico.

Police allege that each of them posted similar warnings about gunmen taking children hostage as parents rushed to save their kids from the reported violence.

The pair believed that they were warning of a real threat after hearing rumors of an attack that later proved untrue, their attorney said. The case immediately drew world attention as a civil liberties abuse.

The government was shamed into setting them free, said Ordonez.

Veracruz lawmakers this week watered down the original law that could have seen the pair sent to jail for 30 years, opting for lighter sentences on similar charges.

A public outcry continued even after the law was changed, Ordonez said, and that pressure helped lead to the charges being dropped.

(Reporting by Patrick Rucker; editing by Mohammad Zargham)