The new law comes at a time when the country's new leaders are struggling to impose order and rein in armed militias which took part in the 2011 conflict that toppled and killed veteran dictator Muammar Qadhafi.
The spokesperson of the General National Congress, Omar Hmeidan, said the law was passed due to the "exceptional circumstances" of the country, which held its first democratic elections in July after a 42-year dictatorship.
He added that the law does not aim to restrict the right to demonstrate, calling it a measure to combat chaos and "organize demonstrations just like in other countries of the world."
The law, according to a copy obtained by AFP, stipulates that organizers must give the authorities 48-hour notice on the place and time of the event.
Offenders are liable to a prison sentence of up to six months and a fine of up to 5,000 Libyan dinars (about US$4,000). The sentence could be higher if the demonstrator is armed.
Protesters and gunmen have stormed the assembly on several occasions in past weeks, with some entering as far as the chamber where sessions are held and disrupting a session to vote on a new government.
The security of the site has been of concern for the 200 members of the assembly, with one bloc floating the idea of shifting meetings to the east of the country until safety can be guaranteed.