Although Mr. Anwar was freed on bail on Thursday morning, his lawyers said, his arrest was likely to add to political tensions that have grown since the governing party suffered the biggest losses in its history in an election in March.
Mr. Anwar, 61, has strongly denied the accusation of sodomy, which was made last month by a 23-year-old male aide. He called it a political fabrication by the same governing establishment that convicted him on charges of sodomy and corruption in 1998. The sodomy conviction was later overturned. Sex between males is against the law in Malaysia.
After his previous arrest, tens of thousands of supporters challenged the government in the streets.
The manner of Mr. Anwar’s arrest on Wednesday seemed intended to intimidate and to challenge the opposition as much as to enforce the law.
According to one of his lawyers, Sankara Nair, who said he witnessed the arrest, Mr. Anwar was pulled roughly from his car and driven to the police headquarters just one hour before he had promised to turn himself in.
Another of his lawyers, William Leong, said, “If it had been an ordinary investigation, then they should have allowed him to go to the police headquarters as has been agreed and they should have allowed him to make his statement.”
During his previous arrest Mr. Anwar was famously punched in the eye by a high-ranking police officer, who later apologized to him when the Federal Court set him free in 2004.
Both times, the charges were brought at a moment when Mr. Anwar was posing a serious challenge to incumbent prime ministers, first Mahatir Mohamad and now Dr. Mahathir’s successor, Abdullah Badawi.
In 1998, as deputy prime minister and finance minister, Mr. Anwar had been Dr. Mahathir’s chosen successor but had apparently pushed his own ambitions too quickly for the prime minister’s taste.
The sodomy conviction was overturned after Dr. Mahathir had left office, after Mr. Anwar had served six years in prison.
By then, Malaysian politics had moved on, with a new prime minister and new contenders for power, and most analysts said chances were slim for a revival of Mr. Anwar’s political career.
But Dr. Mahathir has turned against Mr. Abdullah, who had been his new designated successor, and the government has been seriously weakened by its disaster in the March election.
At that time, the governing Barisan Nasional coalition lost its two-thirds parliamentary majority and ceded five states to the opposition, and Mr. Anwar’s challenge gained credibility and momentum.
About 400 supporters gathered outside the police headquarters on Wednesday demanding his release, and police officers in riot gear warned the crowd to disperse or face arrest. Mr. Anwar’s supporters replied with a warning of their own.
“Why are the police trying to test the people’s patience?” said Azmin Ali, a leader of Mr. Anwar’s party, the People Justice Party. “I am giving a very strong reminder to the police, don’t provoke us.”
The government denied that politics was involved in the sodomy accusation. “The purpose of the investigations is not to fix someone but is to really help him clear his name,” said Shahrir Samad, the domestic trade minister.