Erdogan has accused the pro-Kurdish HDP, parliament's third-biggest party, of being the political wing of militants who have waged a three-decade insurgency in Turkey's largely Kurdish southeast. He wants to see them prosecuted.
The HDP denies links with militants of the outlawed Kurdistan Workers Party (PKK). It fears an overwhelming majority of its 59 deputies could be jailed under the new law, mostly for views they have expressed.
Lawmakers have until now enjoyed immunity from prosecution. The new law allows prosecutors to pursue any of the 138 members of parliament who are currently under investigation. Of those, 101 are from the HDP or Turkey's main opposition party CHP.
Erdogan's opponents say the lifting of immunity is part of a strategy to push the HDP out of parliament, strengthen the ruling AK Party - which he co-founded more than a decade ago - and consolidate support in the assembly for an executive presidential system he has long sought.
The legislation has increased concerns in the European Union about Turkey's record on democracy and human rights at a time when the bloc is also trying to implement a controversial deal with Ankara aimed at stemming illegal migration to Europe from Turkish shores.