The law requires major social media companies such as Facebook and Twitter to keep representative offices in Turkey to deal with complaints against content on their platforms.
If a social media company refuses to designate an official representative, the legislation mandates steep fines, advertising bans and bandwidth reductions.
With a court ruling, bandwidth would be reduced by 50% and then by 50% to 90%. Bandwidth reductions mean social media networks would be too slow to use.
The firms’ representatives will be be tasked with responding to individual requests to take down content violating privacy and personal rights within 48 hours or to provide grounds for rejection.
The company would be held liable for damages if the content is not removed or blocked within 24 hours.
Most alarmingly, the new legislation also would require social media providers to store user data in Turkey.
The government says the legislation was needed to combat cyber crime and protect users.
Speaking in parliament on Wednesday morning, ruling party legislator Rumeysa Kadak said it would be used to remove posts that contain cyber bullying and insults against women.
Opposition MPs said the law would further limit freedom of expression in a country where the media is already under tight government control and dozens of journalists are in jail.
Hundreds of people have been investigated and some arrested over social media posts.
Turkish president Recep Tayyip Erdogan has demanded the law, vowing to “control social media platforms” and eradicate immorality.
Turkey leads the world in removal requests to Twitter, with more than 6,000 demands recorded for the first half of 2019, the most recent set of figures available.
More than 408,000 websites are blocked in Turkey, according to The Freedom of Expression Association.
Online encyclopedia Wikipedia was blocked for nearly three years before Turkey’s top court ruled that the ban violated the right to freedom of expression and ordered it unblocked.
The law passed after 16 hours of tense deliberations in parliament, where Mr Erdogan’s ruling party and its nationalist ally hold the majority of seats.
It will be published in the Official Gazette after Mr Erdogan approves it.