Under the new law, social media giants such as Facebook and Twitter have to ensure 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 must be stored locally.
If companies refuse to comply, they will face fines and restriction of bandwidth making the platform unusable.
The bill was submitted by the ruling AKP and its nationalist partner the MHP, which have a majority in the parliament, and passed after debates beginning on Tuesday and lasting into Wednesday.
After the night-long debate, the parliament went into summer recess till October.