Bashir's arrest on April 30 was "carried out by police according to procedures which are stipulated in the penal code," Chief Judge Harry Sasongko said at a South Jakarta district court.
Sasongko said police had also convinced the court they had enough evidence to build a case against Bashir, whom they allege is the leader of the Jemaah Islamiyah (JI) network, with alleged links to al-Qaida.
"Allahu Akbar!" (God is greatest) shouted some of Bashir's supporters inside the court in a defiant response to the ruling.
The lawyers had brought a lawsuit against national police chief General Da'i Bachtiar, demanding the release of Bashir. They argued that police had not followed proper procedures in his arrest and were acting under pressure from the United States.
One of them, Ahmad Michdan, said he would appeal the ruling to the Supreme Court. "The panel of judges still do not have the guts to carry out a breakthrough against cases with political nuances," he told reporters.
Police say they have new evidence that Bashir, 65, led JI after a court earlier cleared him of the charge.
"The panel of judges still do not have the guts to carry out a breakthrough against cases with political nuances,"
Lawyer for Bashir
They rearrested him on 30 April as he stepped out of a Jakarta prison after completing a sentence for minor immigration violations.
Lawyers for Bashir said he never saw the identification of the arresting officer and he and his family were not given copies of the arrest warrant as required by law.
Bashir, who was not present in court for the hearing, has denied involvement in terrorism and has said the allegations were a US-inspired smear campaign against Islam.
Indonesian authorities say Bashir, by virtue of his alleged leadership of JI, will be charged with involvement in attacks between 1999 and 2002, including the Bali nightclub bombings.
Police are holding him under an anti-terror law which allows detention without trial for six months, better known as administrative detention.
A court last September jailed Bashir for four years due to involvement in a JI plot to overthrow the government but said there was no proof he led the network.
Police are accused of not following
proper arrest procedures
An appeal court overturned the treason conviction but ruled that Bashir must serve three years for immigration-related offences. The Supreme Court later halved that sentence.
In a separate case, a suspected JI member who was deported by Malaysia last month, Muhammad Iqbal Abd al-Rahman, is also suing police for arresting him for alleged immigration offences.
His lawyer Michdan said Iqbal's name change in his passport, which the allegation centres around, was official. Michdan said Iqbal decided to change his childhood name after he performed a pilgrimage to Makka.
"He was freed in Malaysia but why are they detaining him now?" Michdan told reporters.
Iqbal was deported last month just hours before the Malaysian High Court was due to hear an application for his release. The court decided that he should be released, according to Michdan.