Judge Datuk Ab Karim Ab Rahman also ordered two other suspects to be released by 5pm today.
The court issued the order after allowing an application made by the 23-year-old suspect from Libya and his friends - a 20-year-old also from Libya and a 22-year-old from Yemen, who were remanded for five days from Tuesday (Oct 23).
The three suspects were remanded under Section 302 of the Penal Code for murder.
Previously, they were remanded under Section 41 of the Road Transport Act (APJ) 1987.
In his judgment, Ab Karim said the court found that the remand application against the three suspects under Section 302 of the Penal Code did not indicate that the suspects had been released from the previous remand (under Section 41 of the APJ), and then re-arrested.
"This makes the remand application an extension to the previous remand that violates Section 117 (2) of the Criminal Procedure Code, and also, the magistrate does not give any reason for the detention (remand under Section 302 of the Penal Code).
"The court is reviewing the order made by the Sepang Magistrate's Court and the three suspects are to be released immediately before 5pm," he added.
Earlier, Dinesh Muthal's lawyer argued that he believed that the magistrate had erred when issuing a five-day remand order for an investigation under Section 302 of the Penal Code.
He said the provisions under Section 117 of the KPJ did not allow the police to recapture the suspect under Section 302 of the Penal Code using the same facts as the remand application under Section 41 APJ.
"I am not saying my client is innocent but the procedure of the law has been misused," he said.
The three suspects were also represented by lawyers Luqman Mazlan, Mohd Redhuan Mohamed Yusoff, Jeremy Vinesh, Mehnagha Luckhmana and Nur Siti Fairuz Roslan while Ahmad Nazneen Zulkifli appeared for the prosecution.
A footage of a video that went viral on social media showed Wan Amirah being hit by a car as she was crossing Shaftsbury Square at 7.30 pm on Wednesday (Oct 17).
She was dragged for several metres along the road. She suffered serious injuries and was taken to Putrajaya Hospital where she died the following day.