The anti-terror legislation, signed by President Yameen Abdul Gayoom on Wednesday, follows reports that many IS recruits were coming from the Indian Ocean archipelago of just 350,000 people.
The opposition criticized the law as draconian and warned it could be used to crack down on dissent.
"This is an unconstitutional law that will be used to suppress dissent and jail opposition leaders," opposition Maldivian Democratic party spokesman Hamid Abdul Gaffoor said.
Home Minister Umar Naseer said the government has details on seven Maldivian IS fighters, while another 10 people were stopped in Sri Lanka and Malaysia on suspicion of trying to get to Syria to join the group. They were not arrested because there previously was no legal provision, Naseer said. The new law, however, would allow for arrests.
More From This Section
The law defines terrorism broadly, including cases of endangering another person, hijacking a transportation vessel, kidnapping, endangering public safety, vandalism and causing health hazards.
The legislation allows the president to declare any group a terrorist organization. Anyone belonging to such an organization would then be in danger of being imprisoned for up to 15 years.
Anyone who gives a speech that authorities believe encourages terrorism can be prosecuted, along with any media that report on such speeches. Authorities can hold suspects for 96 hours for questioning without a court hearing, and suspects are allowed to meet with their lawyers only in the presence of police.