As anger increases over a territorial dispute between China and Japan, Chinese authorities have been playing both sides of the issue by quietly encouraging recent anti-Japanese protests, then publicly reining them in.

Experts point to signs that Chinese authorities have cleared the way and, in some cases, even fueled some of the protests that have erupted in recent days. At the same time, officials have been careful to keep control over the masses, leery that gatherings of malcontents could easily turn against China’s government.

China analysts say that the two-pronged approach is carefully calibrated to increase pressure on Japan, but that it is also driven by domestic politics, as officials jockey for position ahead of the approaching, once-in-a-decade leadership transition.

“The party is skilled at manipulating such public opinion . . . and the signs that these demonstrations were organized by the government is very high,” said Liu Junning, a former researcher at a government-related think tank and now an independent political analyst. “The protests come when the leaders need one to come, and the protests will stop when they want them to stop.”

On Monday, Chinese officials sent signals that they were looking to taper the protests over the disputed islands — called Senkaku by Japan and Diaoyu by China — especially in the face of their effects on China-Japan trade.

Some Japanese companies on Monday temporarily shut down their factories in China, and there were reports of work stoppages for brand names such as Nissan, Mazda and Canon. Air tickets from China to Japan have reportedly been canceled en masse. Many Japanese-brand stores closed and posted Chinese flags on their doors to ward off vandals and posters swearing their love for and allegiance to China.

The precautions followed violent protests over the weekend. Eggs and bottles were thrown at the Japanese Embassy in Beijing, businesses’ windows were smashed and Japanese cars were bashed on streets across China. In southern parts of the country, protesters clashed with riot police.

Editorials by most major state-run media in China on Monday called for restraint, “sensible patriotism” and “levelheadedness.” Authorities also significantly bulked up the police presence in Beijing and threatened the arrest of “unlawful” protesters in certain regions in preparation for Tuesday’s anniversary of the Japanese invasion of China in the 1930s.

The anger is rooted in bitterness that has lingered in China for decades. Chinese leaders are using those feelings in part for reasons that have little to do with Japan, experts say.

Even as early as last Tuesday, as small groups began demonstrating in front of the Japanese Embassy, there were signs of government encouragement. Mistaken for protesters, two journalists passing by were met by plainclothes police officers and instructed on where to go to more effectively protest.

Interviews with protesters were monitored by plainclothes police, who allowed some to express their anger at Japan but swiftly intervened in several cases when questions turned personal. They asked how the protesters had heard of the demonstration and where they worked.

In past cases, such as anti-U.S. protests, local officials have been known to organize students and others, busing them in to increase the numbers and even providing flags for them to wave.

Chinese journalists say that in recent days they have been given instructions by propaganda officials to report on the nationalistic, patriotic nature of the demonstrations, but not to emphasize any violence. Many blog posts criticizing the protests and violence were wiped off China’s microblogs.

One post that quickly went viral compared a protest leader in Xian to the ID photo of a local police official as proof that the police were organizing some aspects of the protests — an allegation local police denied.

But the biggest proof of government encouragement of the protests is that they happened at all.

Communist Party officials, anxious about retaining their grip on power, allow virtually no protests critical of their government. Demonstrations are banned without legal registration.

But there are competing theories about who within the government is encouraging recent anti-Japan protests and why.

Some analysts contend that rival factions, such as the security ministry or the military, are using them to gain political power ahead of the leadership change in coming weeks that will appoint China’s top leaders for the next decade. Others point to specific banners and well-organized groups of protesters in outdated Maoist garb in certain areas as proof that supporters of recently fallen leader Bo Xilai are using the anti-Japanese demonstrations as an excuse to push their leftist ideology and rally support for Bo.

Most experts believe that the party is using the demonstrations to release built-up pressure and frustration among citizens and to redirect their attention to foreign issues rather than dwelling on mounting internal problems.

“Foreign threats are certainly a useful diversion during a period when people would otherwise be paying attention to the domestic issues and leadership,” said Susan Shirk, a former U.S. deputy assistant secretary of state for Asia.

“This is also happening at a moment of succession, when everyone is competing with everyone else for a seat in the system. You can’t go wrong by talking tough on Japan.”

Liu Liu and Zhang Jie contributed to this report.