I was asked to lecture at Beijing University on soft power, the ability to use attraction and persuasion to get what you want without force or payment. This was before the series of revolutions roiling the Middle East, in whose aftermath China is clamping down on the Internet and jailing human rights lawyers, once again torpedoing its soft-power campaign. The auditorium that day was packed, and I had been told that more than a thousand articles have been published in China on this topic. That may have something to do with the fact that in 2007, President Hu Jintao told the 17th Congress of the Communist Party that China needed to increase its soft power.

Over the past decade, China’s economic and military might have grown impressively. But that has frightened its neighbors into looking for allies to balance rising Chinese hard power. The key is that if a country can also increase its power of attraction, its neighbors feel less need to balance its power. Canada and Mexico, for example, do not seek alliances with China to balance American power the way Asian countries seek an American presence to balance China.

The result of this regional wariness is that China is spending billions on a charm offensive to increase its soft power. Chinese aid programs to Africa and Latin America are not limited by the institutional or human rights concerns that constrain Western aid. The Chinese style emphasizes high-profile gestures, such as rebuilding the Cambodian Parliament or Mozambique’s Foreign Affairs Ministry. The elaborately staged 2008 Beijing Olympics enhanced China’s reputation, and the 2010 Shanghai Expo attracted more than 70 million visitors. The Boao Forum for Asia on Hainan Island annually attracts nearly 2,000 Asian politicians and business leaders to what is billed as an “Asian Davos.”

China has always had an attractive traditional culture, and now it has created several hundred Confucius Institutes around the world to teach its language and culture. The enrollment of foreign students in China has increased from 36,000 a decade ago to 240,000 last year. While Voice of America has been cutting its Chinese broadcasts, China Radio International has been increasing its broadcasts in English to 24 hours a day. In 2009, Beijing announced plans to spend billions developing global media giants to compete with Bloomberg, Time Warner and Viacom. Further examples of Beijing’s efforts to use soft power rather than military might to win friends abroad — or at least placate wary neighbors — include its investment in 2009-10 of $8.9 billion in external publicity work, including a 24-hour Xinhua cable news channel designed to imitate al-Jazeera. During Hu Jintao’s state visit to Washington in January, Beijing rented video screens in Times Square to present attractive pictures of China.

For all these efforts, however, China has had a limited return on its investment. A recent BBC poll found that opinions of China’s influence are positive in much of Africa and Latin America but predominantly negative in the United States, Europe, India, Japan and South Korea. Similarly, a poll taken in Asia after the Beijing Olympics found that China’s charm offensive had been ineffective.

Great powers often try to use culture and narrative to create soft power that promotes their advantage, but it is not an easy sell when it is inconsistent with their domestic realities.

Shortly after the 2008 Olympics, China’s domestic crackdown in Tibet and Xianjiang and its resumed pressure on human rights activists undercut the very gains in soft power it had built up. The Shanghai Expo was a great success but was followed by the jailing of Nobel Peace laureate Liu Xiaobo. And for all the efforts to turn Xinhua and China Central Television into competitors of CNN and the BBC, there is little international audience for brittle propaganda. In the wake of the Middle East revolutions, China is tightening its controls on the Internet and arresting activists for fear that the Egyptian example might inspire similar protests. A few futile efforts by demonstrators have been quickly suppressed by Chinese police.

After my lecture at Beijing University, a student asked how China could increase its soft power. I suggested that he ask himself why India’s Bollywood films command far greater international audiences than do Chinese films. Does India have better directors and actors? When Zhang Yimou, the acclaimed Chinese director, was asked a similar question, he replied that films about contemporary China are neutered by the censors. I told the student that much of a country’s soft power is generated by its civil society and that China had to lighten up on its censorship and controls if it wished to succeed. But I also admitted that he would probably not find my answer very helpful.

Joseph S. Nye Jr. is a professor at Harvard University’s Kennedy School of Government and is the author of “The Future of Power.”