China’s move to douse any flicker of dissent was the harshest in years outside of the restive ethnic regions in the far west, and the vast majority of those detained in the crackdown were, like Mr. Ai, held in secret locations for weeks with no legal justification.

Chinese officials announced in May that the authorities were investigating Mr. Ai on suspicion of tax evasion, after police officers took him from the main Beijing airport on April 3 as he prepared to board a flight to Hong Kong. Supporters of Mr. Ai said the tax inquiry was a pretext to silence one of the most vocal critics of the Chinese Communist Party.

Mr. Ai is presumed to be well connected because he is the son of Ai Qing, one of the most beloved poets of modern China. His detention was nearly certain to have been approved by top Chinese leaders. It is unclear what kinds of discussions took place within elite political circles that ultimately led to his release.

But China came under unusually heavy pressure from all corners of the globe, not only from standard diplomatic channels but also from prominent people like Mayor Michael R. Bloomberg of New York, who harangued China in May at a Manhattan opening of an outdoor sculpture exhibition by Mr. Ai, and Anish Kapoor, a leading sculptor in Britain who this month canceled a show planned for the National Museum of China in Beijing. Prime Minister Wen Jiabao of China was scheduled to visit Britain and Germany starting on Saturday, and he almost certainly would have encountered protests and condemnation, whether on the streets or in private meetings.

“Without the wave of international support for Ai and the popular expressions of dismay and disgust about the circumstances of his disappearance and detention, it’s highly unlikely the Chinese government would have released him,” Phelim Kine, an Asia researcher for Human Rights Watch, said in an e-mail. “The public announcement of his release signals that the Chinese government has had to respond to this pressure and that the cost-benefit ratio of continuing to detain him was no longer tenable.”