LIKE toddlers scrapping over rubber ducks in a bathtub, countries are again quarrelling about the control of islets in the seas between them. The latest spat has blown up between Japan and China over an uninhabited archipelago. If ownership were to change, it would create a new sea border between the countries.

Maritime disputes are unlikely to go away soon. More than half the world’s sea borders—imaginary lines where countries meet—remain undrawn. Luckily, not all disputes end up triggering nationalist emotions or worse. Rather, a slow-motion scramble to fill in the gaps pushes on, with highly paid lawyers debating old maps, analysing treaties and thrashing out deals.

Once defined by the range of a cannon shot from the shore, sovereignty over coastal waters has since 1982 been guided by the United Nations Convention on the Law of the Sea (UNCLOS). Signatories can claim a “territorial sea” up to 12 nautical miles (22km) from their shoreline, inside which they can set laws but not meddle with international shipping (see diagram).

Beyond the territorial sea there is a 200-mile “exclusive economic zone” (EEZ), where coastal countries have the sole rights to resources. When two EEZs collide, UNCLOS calls for an equidistant line between the coasts, splitting the shared gulf or strait down the middle. The theory sounds simple, but the practice is complicated: islands, rocks, historic sovereignty and natural resources can bend the line. In May the International Court of Justice (ICJ), based in The Hague, began deliberating on a case between Colombia and Nicaragua over a piece of the Caribbean. The Colombians claim to have been given the area in a 1928 treaty which the Nicaraguans say is void—signed on their behalf by American occupiers. The case rests in part on a tiny sandbank named Quitasueño, which, if defined as an “island” by the court, will be Colombian territory. Bangladesh has taken India to court over an oil-rich area in the Bay of Bengal. Claiming a line drawn seaward from its concave coast would be unfair, Bangladesh wants a “nuanced” boundary, accounting for undersea geology and a sandbank. India disagrees, preferring a straight line from the land border. This might block some of Bangladesh’s oil claims, but it would set the stage for exploration. That UNCLOS allows for such wrangling is its greatest strength, says Richard Schofield, a borders expert at King’s College London. Since it emphasises fairness and historical facts on the ground over dogmatic adherence to geometry, the convention has probably prevented conflict. Lines in the sea, once drawn by big powers, are now subject to reasoned debate.

Sometimes, however, governments try to game the process. In a long-running case against Bahrain at the ICJ, Qatar produced 81 historical maps showing local sovereignty over their surrounding sea—which turned out to be elaborate fakes.

Not everybody is happy with the set-up. Of the main courts that rule on maritime boundaries—the ICJ, the Permanent Court of Arbitration and the International Tribunal for the Law of the Sea—only the ICJ can enforce its decisions (to which the parties have to submit in advance, which Japan refuses to do in its current spat with China). And if a dispute involves overlapping claims, diplomacy will dominate, as is the case in the South China Sea, a hotly disputed space.

Yet for the majority of disputes, the courts can provide fair results. It may take decades to finish the job, but a long wait is better than the alternative. In the words of one international lawyer: going to court is always cheaper than going to war.