The six Socialist Party of Malaysia members were arrested on July 2 under the Emergency Ordinance, which allows indefinite detention without trial.
They were arrested together with 25 others on their way to a party rally in northern Penang state and initially detained on accusations of "inciting people to wage war against the king".
A subsequent rally on July 9 calling for electoral reform was crushed by police, who arrested more than 1,700 people after thousands defied official warnings and took to the streets in the capital Kuala Lumpur.
Following their arrest, activists held candlelight vigils to demand their freedom.
"Yes the six people held by police for the past 28 days have been freed. They are fine," M. Sivaranjani, a member of the Socialist Party, told AFP.
"The government had come under tremendous pressure to release them."
In a rare move, members of the ruling coalition had appealed to Prime Minister Najib Razak to release the six, warning their continued detention would have negative impact on the coalition in a forthcoming general election.
Security laws such as the Internal Security Act and Emergency Ordinance used to be used frequently to detain activists and opposition politicians, but in recent years fewer such arrests have been made.