Although demonstrating a special knack for antagonizing most their neighbors, Chinese leaders appear to take special pleasure in isolating Japan. This is undoubtedly rooted in their continued anger at Imperial Japan’s despicable actions during its occupation of China, and the perception that Tokyo has yet to show sufficient remorse for these past transgressions.

Although entirely understandable, the Chinese Communist Party’s continued anger at Japan rests uncomfortably alongside the reality that it has benefitted greatly from Tokyo. While in no way justifying Imperial Japan’s inexcusable atrocities—which were done with the sole intent of benefiting Japan and the empire—this does create an awkward situation for the Chinese Communist Party, which regularly stirs up anger at Japan in order to bolster its rule at home.

In his recent book, David Lampton argues that China underwent three revolutions during the twentieth century: the collapse of the Qing Empire in 1911, the establishment of the People’s Republic of China under CCP rule in 1949, and the reform and opening up period inaugurated by Deng Xiaoping in the late 1970s. Japan has played a crucial role in all these revolutions and was also indispensable in creating the Chinese nationalism that the CCP utilizes to great effect today.

Japan played a leading role in the Qing Empire’s collapse in two ways. The first was its defeat of China in the 1895 Sino-Japanese War, and its subsequent encroachments on Chinese territory. By the time of the war, the Qing Empire’s control over China had already been greatly weakened by its inability to defend Chinese sovereignty from Western powers.

Nonetheless, China’s defeat in the 1895 war was particularly devastating for the legitimacy of the Qing government. Unlike the European powers, the Chinese had since time millennia viewed itself as vastly superior to the Eastern Barbarians, as Chinese often called the Japanese. The fact that Japan had defeated a larger and supposedly modernizing Chinese military force and wrested control of Taiwan (and then Korea) from China deeply undermined domestic support for the Qing Empire. These humiliations at the hands of Japan would become a rallying cry for many of the domestic forces that contributed to the Qing’s collapse in 1911.

As Odd Arne Westad has pointed out, China’s defeat in the 1895 war also paradoxically led some Chinese to view Japan as a source of inspiration for the kind of modernizations that Beijing desperately needed to undertake. Thus, following the war and into the first decade of the twentieth century, the number of Chinese studying in Japan vastly increased. Especially notable with regards to the Qing regime’s collapse, many of the dynasty’s most ardent critics lived in exile in Japan, including Sun Yat-Sen and Chen Duxiu (who would go on to cofound the CCP). Many of these exiles in Japan would go on to play a leading role in the dynasty’s collapse.

It was also largely among this Chinese diaspora living in Japan in the late nineteenth and early twentieth century that the idea of Chinese nationalism began to take root. As Westad observes, “The two key concepts that Chinese in Japan and elsewhere discussed in the first decade of the new century were nationalism and republicanism.” Indeed, opposition to the Qing Dynasty and the growing sense of nationalism were intricately tied together for these Chinese living in Japan. As was true in China itself, these exiles increasingly framed their opposition to Qing rule in ethnic terms, protesting the fact that the Qing elite were Manchus governing a largely Han state. This contradiction, as many Han Chinese saw it, was at the heart of China’s declining place in the region and the world. Not surprisingly, many framed not only their opposition to Qing rule, but also their ideas for what should replace it in terms of Chinese nationalism. For instance, Hu Hanmin, a key Kuomintang (KMT) leader who spent some of the 1900s in Japan, would write: “We can overthrow the Manchus and establish our state because Chinese nationalism and democratic thought are [now] well developed.”

But Tokyo’s largest contribution to Chinese nationalism was the invasion of Manchuria and the second Sino-Japanese War (1937-1945). As two scholars put it, “the plain historical fact [is] that modern Chinese nationalism emerged above all in reaction to Japanese imperialism.” Indeed, in the run-up to the second war, China remained deeply divided along regional, ethnic and ideological grounds. All these disparate actors united immediately prior to the war in hopes that they could defend the country from Japan. The brutality of Japan’s occupation further ingrained Chinese nationalism into the national consciousness. In doing so, Japan made it possible for Mao and the CCP to unify China after the Chinese Civil War (1945-1949).

Much later on, after it abandoned communist dogma, this strong sense of Chinese nationalism became the ideological pillar of the CCP’s rule. It continues to be the regime’s dominant ideology to this very day, and Japan is often the impetus the CCP uses to stoke it.

But Japan’s invasion of China benefited the CCP long before contemporary times. Indeed, it’s virtually inconceivable that the CCP would’ve come to power at all had it not been for Imperial Japan’s invasion. Before the second Sino-Japanese War commenced, the Communist Party was locked in a death struggle with Chiang Kai-shek and the KMT. The CCP fared poorly in this conflict, suffering repeated defeats at the hands of the Nationalists.

By the end of 1934, the CCP was on the verge of extinction after KMT troops delivered another heavy blow to the Red Army in Jiangxi Province, which forced the party to undertake the now infamous Long March to Xi'an in the northwestern province of Shaanxi. Chiang initially pursued the Communist forces, and would have almost certainly delivered a final blow to the CCP if war with Japan could have been delayed. As it turned out, Chiang was not able to put off the war with Japan any longer, and domestic and international pressure forced him to accept a tacit alliance with the CCP against Japan.

The war with Japan devastated the Nationalist forces, which bore the brunt of fighting Japan, even as it rejuvenated the CCP. Over the course of the war, the CCP went from being on the verge of defeat to flourishing as it had never done before. Its guerilla warfare against the Japanese occupiers helped bolster local support for the party, allowing it to establish a rural base. The Maoist guerilla warfare tactics also allowed the CCP to preserve its strength for the inevitable civil war with the Nationalists. Both factors proved crucial following Japan’s defeat, when the CCP would mobilize its new base to successfully defeat the Nationalists under Chiang. By the end of 1949, the CCP had control over most of mainland China.

While Mao was successful in consolidating CCP control over China, his subsequent policies devastated the country. By the time of his death, the great hardships that the Chinese suffered under Mao’s reign had greatly sapped the CCP’s legitimacy. Mao’s rule also saw China become even more backwards relative to its neighbors.

Thus, following Mao’s death and the arrest of the Gang of Four, Deng Xiaoping and the Eight Immortals sought to shore up support by restoring the Four Modernizations. In doing so, senior-level CCP officials began taking study tours abroad to observe how other countries’ economies operated. From this, they grasped just how far behind China had fallen economically, and realized that acquiring foreign assistance would be essential for successfully modernizing quickly. As Deng termed it: “Recently our comrades had a look abroad. The more we see, the more we realize how backward we are.”

Lin Hujia, deputy head of the Shanghai Revolutionary Committee, led a delegation of Chinese economic officials to Japan for a nearly month-long visit in March and April 1978. Upon their return, the delegation reported on Japan’s economic progress and its willingness to help China modernize. Immediately after, bilateral negotiations over a peace treaty were accelerated after years of gridlock. A treaty was signed in August, and Deng himself famously visited Japan in October 1978. He was the first Chinese leader to ever visit the country. During the trip, Deng said that he had come to Japan to find the “secret magic drug,” which he explained was how to modernize one’s economy.

Deng’s trip accelerated Sino-Japanese economic ties considerably. A trade relationship developed whereby Japan would sell China advanced technology in return for natural resources. Already by the late 1970s Japan accounted for 25 percent of China’s entire trade. By the mid-1980s, this figure had grown to 30 percent. Altogether, bilateral trade would grow more than tenfold in the twenty years between 1979 and 1999. Although more gradual at first, Japan’s foreign direct investment (FDI) picked up after the signing of the bilateral investment protection pact in 1988. As a result, Japan’s FDI in China grew from 50.7 billion yen ($497 million) in 1990 to 421.8 billion yen ($4.1 billion) in 1995.

The Japanese government played a pivotal role in fostering these economic ties. Between 1979 and 1997, the Overseas Economic Cooperation Fund (OECF), the Japanese government's development financing arm, gave China 2.54 trillion yen ($24.9 billion) in long-term, low-interest loans. In addition, Japan's External Trade Organization established offices in China to encourage Japanese firms to set up training programs in China. As Ezra Vogel has remarked, “During Deng's years at the helm, no country played a greater role in assisting China build its industry and infrastructure than Japan.”

In short, Japan’s interactions with China time and again served to bolster the CCP at crucial moments in its history. This in no way excuses the horrible atrocities Japan committed during its occupation of China, but it does provide interesting context on the CCP’s use of anti-Japan sentiments to bolster support for its domestic and foreign policies.

Zachary Keck is Associate Editor of The Diplomat where he authors The Pacific Realist blog. You can find him on Twitter: @ZacharyKeck.