When new countries rise to power, the transition can end badly, often in war. Harvard’s Graham Allison has argued in The Atlantic that “judging by the historical record, war is more likely than not” between the United States, the world’s current reigning superpower, and China, a rising military and economic force. There is considerable debate on this point, but American pundits and presidential candidates often talk as if China were already an American adversary; Donald Trump has warned, for example, that China will “take us down.” Yet few in the United States seem worried about Asia’s other rising giant, India.

To the contrary, there’s a temptation to support India, a like-minded democracy, as a counterweight against the growing power of authoritarian China. But if American leaders feel confident India can accumulate power without becoming an antagonist, can they find a way to make the same true for China?

The United States is not the only world power to have faced the rise of two potential challengers simultaneously. The British Empire encountered a similar situation in the late 19th century, as two other powers encroached on its dominance in world politics. Both these rivals had strong economies, were rapidly industrializing, and sought a place for themselves in the international order. One, Germany, was a monarchy, and the other, the United States, was a democracy. Both shared some, but not all, of Britain’s values. Yet Britain handled each very differently.

The analogy is, like all historical analogies, imperfect. But it yields a view of the possible paths America could follow as it navigates a similar environment. Over several decades, Britain’s leaders chose to accommodate the rise of the United States, believing that the country would generally align itself with the rules of the international system Britain had established. British leaders tolerated many disagreements with their U.S. counterparts as America’s power grew—including America’s land grab in the Mexican War, and its practice of slavery, which the British outlawed in 1831. But Britain also set clear, consistent boundaries, for example by threatening war over America’s audacious 1845 claims on the Oregon Territory, over which it shared sovereignty with Britain. The two avoided major conflicts and ultimately became staunch allies.

By contrast, while Britain made some friendly overtures to Germany as well, it treated Germany mostly as a rival to be balanced. The scramble for African colonies after the Suez Canal opened in 1869, and the fact that railroads began cutting into the advantages of Britain’s maritime dominance, fueled the rivalry. Both countries rapidly built up their navies in the lead-up to World War I, and ultimately fought two devastating wars.

Some may argue that the history of the 20th century justifies British judgment that Germany was uniquely dangerous—and extrapolate the parallel to contemporary China. But Britain might have been in a much stronger position to handle the rise of fascism following World War I if it had remained aloof from the continental struggle of 1914 to 1918 that devastated British power. And it merits remembering that American international behavior in the 19th century was not so different from that of Germany, irrespective of its domestic political creed.

The British-American alliance was by no means inevitable just because the United States was a like-minded state. Britain had as much in common with Germany politically in the 19th century as it did with the United States. British efforts to cooperate with America predate Britain’s own move towards democracy in the 1860s. Prior to that, both Britain and Germany were monarchies. The British fought two wars against the United States, the Revolutionary War beginning in 1775, and the War of 1812. Far from being preordained, today’s British-American alliance was the result of steady, thoughtful policies and an effort to find common cause.

* * *

China’s military build-up and intimidation of weaker statesin particular its efforts to build on islands claimed by other powers in the South China Sea—mirrors the aggression of a rising Germany at the turn of the 20th century. But what if American leaders adopted toward both China and India the same perspective the 19th-century British held toward the upstart Americans?

Just as Britain benefited by creating incentives for the United States to become a responsible power, America’s own economic strength depends on trading and investing with both China and India, which are the engines of world growth, with joint populations approaching 3 billion people.

Some Americans worry that free trade is threatening U.S. jobs, which are being shipped to places like China and India where labor is cheaper, even while those countries remain protectionist and don’t play fair. During its own rise, the United States was also deeply protectionist—and it was Britain that helped nudge the country toward open trade. British companies invested heavily in America, and in the late 19th century, American companies began to invest in Britain. Understanding that their intervention would likely make U.S. politicians resist, British leaders also wisely stayed out of a lengthy U.S. domestic monetary dispute in the 1890s about moving away from U.K.-dominated gold to a silver standard, a decision that would make American debts payable in a domestically generated currency. It is a debate oddly reminiscent of the current one about the prospect of China’s renminbi becoming one of the world’s international reserve currencies.

It is true that China, and to some extent India, have taken actions that harm the American economy, making cooperation harder. China coddles its “national champions,” permits cyber-spying on U.S. companies, and recently passed a vaguely worded law requiring tech companies to decrypt sensitive user data, and thus expose their users to Chinese government spying when asked. India restricts investment in many sectors, including insurance, petroleum refining, banking, and air transport. Through the World Trade Organization and diplomacy, Washington has ways to combat these practices, and impose consequences when China or India breaks trade rules.

Despite these frustrations, American trade with and investment in China and India is already helping all three economies grow. Chinese investment has directly created more than 80,000 jobs in the United States, with $58.7 billion invested between 2013 and 2015 alone. American exports to China indirectly support hundreds of thousands more jobs in the United States. Indian foreign direct investment is thought to have created at least 90,000 direct jobs in the United States in total; the Indian tech industry alone is estimated to have indirectly supported more than 400,000 U.S. jobs in 2015. Economic cooperation benefits all three.

Military relations are the most difficult to get right and the most likely to lead to catastrophic consequences if leaders in the United States, China, or India mismanage them. Current trends are not promising: The United States is being neither assertive nor inclusive enough. In practice if not explicitly, China departed from its previous policy of “peaceful rise” around 2008. In addition to the country’s activities in the South and East China Seas, Chinese troops recently moved several times into Indian territory over their disputed Himalayan border.

American leaders have been hesitant in their reaction, allowing China to declare exclusive air and sea zones, build islands with military installations, and harass ships in disputed waters. This was met with little more than rhetorical objections—and there were several years in which the U.S. conducted no patrols in the South China Sea. Just recently, the U.S. military restarted freedom-of-navigation patrols. America has ways to oppose China more consistently where their interests differ. It could, for example, conduct regular freedom-of-navigation exercises with other countries in the South China Sea and thus leave China’s military less likely to wonder whether the U.S. is willing to enforce this point.

This is not inconsistent with accommodating China’s legitimate interests—such as protecting the sea-lanes vital to China’s trade and economic health—and finding creative ways to give China the stature all rising powers crave. Including China in many joint exercises and establishing procedures to manage incidents at sea are useful starting points. The United States can also, for example, invite China to participate in some U.S.-South Korean exercises aimed at deterring North Korea, to build trust from each other’s mutual concerns about North Korea’s erratic behavior. This kind of cooperation comes more easily to America and India, and the two militaries exercise frequently together, given their mutual worries about China.

It is lucky that China and India are rising into a world where the institutional order is fairly well-developed. When the United States rose, by contrast, great-power wars were a normal occurrence, but Britain went out of its way cooperate with the United States even where there were disagreements. In the 1890s, for example, both countries together established an international court of arbitration to settle their commercial disputes.

The United States cannot expect China and India to accept, without some changes, the institutions America helped create after World War II. Chinese President Xi Jinping emphasized in a 2015 visit to the United States that China doesn’t want to undermine existing institutions but seeks more influence to match its new position in the world. To underscore this point, China recently almost tripled its contribution to the United Nations budget, increased Chinese peacekeepers by several thousand, and committed several billion dollars in aid for the poorest countries to meet the UN’s sustainable development goals.There are ways to make room for both China and India in existing institutions—by allowing them to have more voting rights in the IMF and World Bank, as both institutions recently, belatedly, did; by supporting India for a UN Security Council seat, as President Obama has done; and by joining China’s new Asian Infrastructure Investment Bank, which the U.S. has refused to do.

The most important step the United States can take to ensure good relations with China and India is not dramatic at all: It is to prioritize goodwill and make cooperation the dominant element of its interactions. Cooperation is not automatic. It must be practiced at the level of diplomacy, business, and interpersonal relations. Britain did this in important ways with the United States in the 19th century. For example, British private capital contributed greatly to the westward expansion of U.S. railroads, and during the Spanish-American War, the British government let the U.S. use the one existing trans-Pacific cable to get information to the U.S. fleet in the Philippines.

Prioritizing goodwill won’t preclude disagreements or competition. But it does mean resolving conflicts in private and prioritizing joint problem-solving in public.

With India, the United States has already taken important steps in this direction. In 2005, the United States agreed to negotiate a civil nuclear-energy agreement with India, which powerfully demonstrated that it supports India’s rise. Those negotiations (in which one of the present authors took part) were often difficult, but they taught each side how to work together. The nuclear agreement has unlocked cooperative behavior on topics from defense sales to intelligence sharing to agricultural partnerships.

The nascent Chinese-American work on climate change, announced in December 2014 after months of tough, private negotiations, is a fantastic start. This agreement then helped prod other countries (including recalcitrant India) into action and achieve a successful outcome at the Paris climate talks in 2015.

America is already well down the path of peaceful accommodation with India. Where China is concerned, it should not leave that path untraveled.