BEIJING -- In a case that drew the attention of millions of Internet users in China, two judges and an official of the Shanghai high court have been expelled from the Communist Party and dismissed from their jobs after being seen on video apparently consorting with prostitutes in glitzy nightclubs.
A disgruntled businessman compiled the videos from security cameras and from footage he shot while trailing the judges. He then posted the videos as a way of seeking justice for what he considered unfair rulings in a commercial suit, which he blamed on meddling by one of the judges he exposed.
The videos circulated on various Web portals for five days before a disciplinary committee in Shanghai for the Communist Party announced the dismissals on Tuesday. According to one estimate, 4.3 million people viewed the images on Youku, China's version of YouTube.
The images, which show middle-age men in open-neck white shirts accompanied by young women in short skirts in hotel corridors, and outside a nightclub called Diamond No. 1, tapped into widespread anger at corruption and excessive spending by party officials.
China's leader, Xi Jinping, began an anticorruption campaign soon after taking power in November, and party officials have tamed lavish expenditures on banquets, liquor and gifts. But there have been no arrests or demotions of senior officials for financial misconduct. A prominent general, Gu Junshan, was arrested on suspicion of corruption before Mr. Xi assumed office. And Bo Xilai, the former party secretary of Chongqing, is likely to stand trial soon on charges of corruption and abusing power.
The uproar about the case was enough that Han Zheng, the Communist Party secretary of Shanghai, issued a statement warning judges and court officials, according to the Web site of the People's Daily newspaper.
"Although this case involved only a few corrupt and dissolute officials, it has shamed the entire judicial and legal system of Shanghai, and, indeed, the entire city itself," Mr. Han said. "Certain judges have spurned law and discipline, forsaken ethics and morality, and behaved with reckless abandon."
The bold disclosure and actions by the businessman, Ni Peiguo, 55, touched a nerve because they showed in lurid detail the behavior of some judges at a time of mounting popular frustration with the court system.
The Shanghai Communist Party's Discipline Inspection Committee said Tuesday that the judges and the court official were dismissed after they had "participated in prostitution" during an evening organized by a construction company manager.
In all, four officials of the Shanghai judiciary were disciplined. The committee said Chen Xueming, chief judge of the No. 1 Civil Tribunal of Shanghai High People's Court, and Zhao Minghua, deputy chief judge of the tribunal, had been dismissed from the party and their jobs. A member of the discipline committee of the high court, Ni Zhengwen, was also expelled from the party, and his job. Wang Guojun, deputy chief judge of another tribunal at the Shanghai court, was placed on two years' probation.
The focus of Mr. Ni, the businessman, appears to have been Mr. Zhao, whom Mr. Ni suspected of exerting unfair influence over rulings that resulted in a major financial loss for Mr. Ni. One video titled "Shanghai Judges Out Whoring" showing Mr. Zhao and Mr. Chen drew particular attention, according to the official newspaper, Legal Weekly, a publication produced by the Justice Ministry.
The state-run media have trumpeted the scandal, and Legal Weekly approvingly detailed Mr. Ni's persistence in following Mr. Zhao, including to a funeral.
"From Monday to Thursday, I would go after work, on Saturdays and Sundays, I would mostly wait outside his house," Mr. Ni was quoted as saying.
Legal Weekly reported Mr. Ni saying that when he spotted Mr. Zhao taking an elevator with his mistress, he then waited five hours in front of the elevator to see the couple come down.
The businessman said he got some of the most incriminating video in June by bribing security guards with two packets of cigarettes at a Shanghai resort that the three judges and the court official had visited.
The disciplinary committee cited that June 9 outing at the Hengshan Resort in the Pudong area of Shanghai, saying the judges and the court officials had been to the resort and patronized prostitutes there. The hotel contains a plaque at the front desk saying, "designated hotel for government and party officials, 2013-2014." The hotel features gyms, saunas and a karaoke bar.
A state-run TV station in the Anhui Province showed footage from the resort visit, with young women in short dresses walking down a corridor after leaving several rooms. One can be seen shoving money down the front of her dress.
In the broadcast, an announcer says the footage "allegedly showed five sexily dressed women entering the rooms of the judges late at night before exiting about half an hour later, with several stuffing money into their bras."
After a year of sleuthing, and with the Hengshan Resort video in hand, Mr. Ni told Legal Weekly he decided he had sufficient footage and hired a professional editor to make the production that he posted last week. Some of the video online shows a red circle around Mr. Zhao, making it easier for viewers to identify him.
The Global Times, a populist tabloid owned by the newspaper People's Daily, said in an editorial that the Communist Party officials should be banned from nightclubs to protect them from the temptations of prostitutes.
"To be frank, improving the moral standards of Chinese officials in a short time under the current situation is a difficult task," said the newspaper, which acts as the government's mouthpiece. But there should be "zero tolerance" for such behavior, the editorial said.
Chris Buckley contributed reporting from Hong Kong.
This article originally appeared in The New York Times.