The On and On Condom Co. set up shop in Shanghai in 1998, dreaming of taking a ride on China's sexual revolution. China's old city of sin was rediscovering its roots in a big way.

By 2000, the firm had contracted with Malaysian manufacturers, received all the necessary approvals from China's state drug administration and was ready to sell. In another good sign for business, China's central government had eliminated customs duties on imported condoms to help fight sexually transmitted diseases and unwanted pregnancies.

But when On and On started hawking condoms to Shanghai pharmacies, grocery stores and supermarkets, it ran into trouble. If you don't go through the city's Family Planning Commission, its representatives were told, you can't sell condoms in Shanghai.

A representative of the firm went to the commission and asked for guidance. Commissioners informed the On and On executive that the Drug Supply Center, an agency under the commission, sets condom prices, controls where they are sold and takes 25 percent off the top of all retail sales. The center said it was not responsible for condom quality. It just required a cut of the sales. The commission, which declined to comment for this article, had basically monopolized condoms sales in Shanghai and was taking a big piece of the action.

As China moves toward a market economy, the tale of the condom trade in Shanghai is a useful reminder of how things often really work. Shanghai, a city where glistening high-rises abut tastefully renovated European-style mansions, has marketed itself as China's window on the world. Its gleaming subway lines, elevated highways, world-class museum and hi-tech magnetic levitation, or maglev, train-to-the-plane give the impression of a city ready to take on the 21st century and win.

But the reality, say economists, is more complex. Shanghai's city government, like other local governments throughout China, fiddles with the market, acting as both player and referee, protecting local interests. The business environment contradicts the government's policies of fighting corruption, adhering to market conditions set by the World Trade Organization and transforming China into a modern economy. Today, for example, it is still almost impossible to buy a Citroen in Shanghai because the cars are produced outside Shanghai, in Wuhan. The reason? Shanghai's city government owns a big stake in the city's joint venture with Volkswagen so it does all it can to help Volkswagen's sales.

Shanghai spent years trying to prevent a General Motors assembly plant from buying car parts outside the city, Western bankers in Shanghai said. Trucks with license plates from outside Shanghai cannot enter the city between 7 a.m. and 9 p.m., giving local shippers a boost.

The condom case is even more unusual because the monopoly has not been instituted to protect a local industry and local workers. Rather, it has been used as a way for government officials to garner personal profits, according to officials and economists who privately criticize the practice. And it appears to violate Chinese law.

In 1996, Shanghai's Family Planning Commission issued Document No. 1, a regulation requiring that commercial birth control items sold in Shanghai be funneled through the city government's Drug Supply Center in each of Shanghai's 17 districts.

Drug Supply Centers play an important role in China's policy to limit couples to only one child. To encourage compliance, each year they distribute more than $80 million in free condoms and other birth control devices nationwide to workers in state-run organizations and farmers.

The document declared that Drug Supply Centers in Shanghai would be entering the commercial birth control market as well. "Retail outlets are forbidden from obtaining birth control products from other channels" besides the Drug Supply Centers, it said.

At the same time, the head of the city's Drug Supply Center, Shao Youjuan, established a company called the Shanghai United Family Planning Service Co., according to incorporation records examined by The Washington Post. This put her in the position of being both a government official and a private businesswoman.

That company became the representative of the Drug Supply Center, delivering condoms from various manufacturers to retail outlets, setting the prices and skimming profits, according to companies that have had dealings with the Center.

"It functioned like a toll booth," said a representative of DKT International, the Washington-based family planning nonprofit organization run by Phil Harvey, founder and chief executive of the world's largest mail-order purveyor of sexual merchandise. "We gave them our products and they gave them to the retail outlets. For that 'service,' they took 25 percent of the revenue."

The Drug Supply Center diligently enforced its monopoly, dispatching government workers -- some of whom also worked for Shao's company -- to shut down retail outlets that dared to obtain condoms from independent channels, according to retailers in Shanghai. Reached in Shanghai, Shao declined comment.

As of this year, the Drug Supply Center -- and its closely affiliated private enterprise -- controlled distribution to 3,496 retail outlets in Shanghai including supermarkets such as Carrefour, where most condom sales occur, according to Chinese news reports.

On and On tried to cooperate. In 2000, it went to the city's Drug Supply Center, handed over samples and an approval slip from the State Drug Administration in Beijing and waited. Company representatives said they believed things would begin to change. On April 1, 2000, the State Council, China's cabinet, issued an order saying that as long as a condom was approved by the State Drug Administration it could be sold in China.

The order worked, for example, in Beijing. There, the mayor, Liu Qi, intervened and got the government out of the condom business.

"We always thought the money earned from this method of doing business was kind of hot," said Li Wenmin, the head of Beijing's Drug Supply Center. "We were playing two roles at once, athlete and referee. But we still miss those profits." Shanghai, however, ignored the order, according to a report last month by a Chinese newsweekly, Southern Weekend. And most of On and On's goods stayed in the warehouse.

Last year, On and On decided to try again to sell directly to retailers. China had changed in the intervening years and two stores were willing to take its goods: a drugstore, Watson's, owned by a Hong-Kong mogul, Li Ka-shing, who has close relations at the top of China's Communist Party, and a chain store, Hua Lian, whose boss is a Communist Party functionary more senior than the head of the Family Planning Committee.

But that was only two chains. On and On says it was locked out of most of the city.

The monopoly by the Drug Supply Centers has also increased condom prices in this city at a time when AIDS has begun to spread rapidly throughout China, fueled by a prostitution boom and sexual revolution that has transformed the nightlife of China's cities.

On weekends, bars in Shanghai and other cities fill with young professionals looking for companionship. Casual affairs, once taboo, are now becoming commonplace in China. Homosexuality, once prosecuted as "hooliganism," is increasingly accepted.

In its report, Southern Weekend, one of China's most daring state-run weeklies, published a piece headlined "Who Is Monopolizing Condoms?' in Shanghai, asking the question: "Where did all the money go?" The head of the Drug Supply Center, Shao, was quoted as saying the center had done nothing wrong. A representative from On and On was quoted as well.

Since that article appeared, On and On says its business has taken a turn for the worse. A company representative has been called into the Shanghai Family Planning Commission and told that its condoms no longer are acceptable even though the commission, under Chinese regulations, does not have the right to make such a determination. Government workers have gone into retail outlets that stocked the brand and told them to pull the condoms from the shelves. Other retailers have been told not to pay On and On for its condoms, sources in Shanghai said.

On and On is thinking about breaking off its Shanghai affair.

"Artificial fingernails," said a representative with a knowing smile. "Now there's a good product."

Merchandise sits idle at the On and On Condom Co. warehouse in Shanghai, where city officials have monopolized condom distribution.Timothy Chan of the On and On Condom Co. displays the company wares he has not been able to sell to Shanghai retail outlets.