Turkey's parliament on Wednesday passed a controversial bill giving the government greater control of social media, a move criticized by human rights advocates as an attempt to increase online censorship.
Under the new law, social media giants such as Facebook and Twitter have to ensure that they have local representatives in Turkey and to comply with court orders over the removal of certain content or face heavy fines.
The legislation targets social networks with more than a million unique visits every day and says servers with Turkish users' data on them must be sited locally.
If companies refuse to comply, they will face fines and restrictions making the platform unusable.
The bill was submitted by the ruling AKP and its nationalist partner the MHP, which have a majority in parliament, and passed after a night-long marathon.
Twitter, contacted by AFP, did not make an immediate comment.
Human rights groups and the opposition are worried over what they call the erosion of freedom of expression in Turkey, with thousands of people subject to criminal proceedings for "insulting" President Recep Tayyip Erdogan on social media.
They argue that increased control will also limit access to independent or critical information in a country where the news media is in the hands of government-friendly businessmen or controlled by the state.
"Why now?" asked Yaman Akdeniz, professor at Istanbul's Bilgi University and a cyber rights expert.
"While print and broadcast media platforms are already under government control, social media networks are relatively free. Social media has become one of the few spaces for free and effective expression in Turkey," he told AFP.
Human Rights Watch expressed concern that the law would enable the government to get content removed at will and to arbitrarily target individual users.
"Social media is a lifeline for many people who use it to access news, so this law signals a new dark era of online censorship," said Tom Porteous, deputy program director at HRW in a statement before the legislation passed.
The measure has aroused deep concerns for many in Turkey who mobilized online in recent weeks using the hashtag "don't touch my social media".
The opposition CHP party said it would apply to the top Constitutional Court for its annulment.
Ibrahim Kalin, Erdogan's spokesman, brushed off fears the law would hamper free speech.
"There is no obstacle to social media users freely expressing their opinion," he told CNN-Turk television on Tuesday.
"Here is the rule: whatever is a crime in the real world is also a crime in cyber world... there must be a limit to criticism."
Erdogan vowed to tighten government control over social media earlier this month after he said "dark-hearted" users insulted Finance Minister Berat Albayrak and his wife Esra, the president's daughter, following the birth of their fourth child.
Last month, the Turkish leader met with a spate of negative comments during a video-conference with young people.
The Turkish presidency then turned off comments but there were 388,000 clicks on the "thumbs down" button, compared with 114,000 on the "thumbs up" button.
Erdogan is not a fan of social media despite a large following on different platforms, including Twitter.
He once compared social media platforms to a "murderer's knife" and previously promised to "eradicate" Twitter.
"I want everyone to share whatever they like on social media," said 20-year-old student Kaan, an Istanbul resident. "Everyone should be able to think and express themselves freely."
The government previously blocked Twitter and YouTube in 2014 after audio recordings were posted implicating the president, then prime minister, and his inner circle in an alleged corruption scandal.
Erdogan's aversion to social media dates back to anti-government protests in 2013, which were often mobilized by Twitter and Facebook posts.
A Turkish court in January lifted a ban on the online encyclopedia Wikipedia after almost three years.
According to Twitter's latest "transparency report" for the first half of 2019, Turkey ranked number one for seeking content removal with more than 6,000 requests.