On January 11, 2007, with no warning, China's military fired a ballistic missile at one of the country's weather satellites and blew it to bits. China's first test of an antisatellite weapon made a mess: tens of thousands of metal shards now litter low-Earth orbit, where the International Space Station, other crewed missions and about half of all operational satellites fly.

Other superpowers have been exploring space-based weaponry. In October 2014 the U.S. Air Force's X-37B Orbital Test Vehicle–3 returned from a mission where some analysts believe it was testing technologies for hypersonic missiles—weapons capable of hitting any target on Earth within an hour—and, possibly, techniques for repairing or disabling satellites. Russia has tested three satellites in recent years that may be able to intercept other orbiting spacecraft to eavesdrop on or physically sabotage them.

This militarization of space is a dangerous course. A small skirmish above our planet could knock out global communications, and the orbiting hazards could lock off access to space for generations. Worse, attacks on satellites could quickly escalate into war on the ground. World powers need to act now to declare space a demilitarized zone.

In 2008 China and Russia made a motion in that direction by proposing a United Nations treaty that would ban weapons in space. But the draft contains no verification process and makes no mention of the kind of Earth-based satellite-killing technology China has been testing. It has been a nonstarter in the U.S. not only because of its loopholes but also because Congress is deeply hostile to any treaty that places limits on the American military. U.S. opposition, joined by that of other balking countries, dooms any U.N. treaty, which would require unanimous approval from all members of the conference in which it is introduced.

This year a more feasible alternative proposed by the European Union was discussed at a disarmament conference. The nonbinding International Code of Conduct for Outer Space Activities calls on countries to maintain the area around our planet as a peaceful global commons, and it sets out practical guidelines for avoiding collisions in space and for minimizing and removing debris. Michael Krepon, co-founder of the Stimson Center, a global peace and security think tank, explains that the code of conduct is modeled on cold war measures such as the Incidents at Sea Agreement between the U.S. and the Soviet Union, which in 1972 established rules for military forces operating in close proximity. Another U.S.–Soviet Union pact, signed in 1989, set expectations for troops using laser range finders, as well as radio channels that could jam other frequencies, actions that could easily be interpreted as hostile. These were not binding treaties, but the U.S. and the Soviet Union adhered to them, and they helped to prevent disaster. This time, however, Russia, China and several other nations have said they will not abide by the E.U.'s proposed space code because they were left out of the drafting process, and they object to some of the code's provisions.

The E.U. should adopt the International Code of Conduct for Outer Space Activities anyway, and the U.S. should join them at the launch. The history of cold war agreements suggests other nations—perhaps eventually even China and Russia—will follow out of self-interest. Nobody wants its satellites destroyed, and in the absence of a treaty, shared standards of nonaggression are just about the only way to achieve that goal. Even the greatest superpower's satellites are easy targets for a motivated attacker, so the best defense is for everyone to agree not to shoot.

Given the alternatives—placing all chips on the vanishingly small possibility of a binding U.N. treaty or doing nothing and hoping for the best—an international code of conduct looks like the best strategy. The Obama administration, Europe and their allies should lead by example and start operating by these standards as soon as possible. International norms have prevented catastrophe before, and they can do it again.