Montgomery County, Alabama's fourth most populous county, is out thousands of dollars after officials were forced to pay a ransom to retrieve stolen data from hackers over the weekend.

The infection, first detected September 19, prevented nearly every government agency within the county from gaining access to its operating systems, files and websites, the Montgomery Advertiser reported.

Though officials first scoffed at the idea of having to pay up, their opinions quickly changed after county administrators realized they wouldn't be able to access their 70 terabytes worth of backup files either, due to a technical error.

"When we went to retrieve the data, we had the vendor come in and try to get to that data," Lou IaIacci, the county's chief IT officer, told local station WSFA 12. "Their recommendation [was] to do a cleanup [but] when we did the cleanup we lost the data."

The county was given seven days to cough up the dough, and cracked on the fourth.

Calling an emergency meeting Friday to authorize the funds, the group decided to pay half of the ransom on Saturday and the other half on Sunday, gaining access to more data each day.

To conduct the transaction, officials first had to purchase 9 bitcoins, ranging in price between $40,000 to $50,000, to pay off the tricksters.

"I hate to say this, but their reputation is that they do return stuff. They think of themselves as modern day Robin Hoods, they are here helping the masses," IaIacci admitted. "They are the good guys: they are going to come in, hack you and grab the files [and] if you pay them, that's your punishment for letting them in."

While the FBI does advise victims against paying cybercriminals to recover stolen files, the warnings have mostly fallen on deaf ears. Per the bureau, in 2016 hackers managed to get their hands on more than $2.4 million, the Washington Times reported.

"You don't think about these things till they happen," Elton Dean, county commission chairman, told the Advertiser Monday. "When you are talking about losing about $5 million worth of files, that's kind of like an emergency situation."

With officials now in recovery mode, IaIacci announced the county would now be setting up precautionary measures to prevent a similar scenario from happening in the future.