President Rodrigo Duterte of the Philippines traveled to Beijing recently, promising to announce his country’s “separation” from the United States and alarming the White House and his own defense secretary.

But something different happened. Instead, Mr. Duterte kept the alliance with the United States intact, appeared to reach an understanding with China to allow Filipino fishermen to return to disputed waters, and, by threatening a geopolitical realignment, distracted from American objections to his country’s growing human rights abuses.

Rather than switch allegiances between the two nations, Mr. Duterte managed to play them off each other, in that way improving his position with both and cementing his image at home as a strong nationalist unbeholden to foreign powers. And he did it while keeping his nation’s security guaranteed by a 65-year-old treaty with the United States.

Whether he knows it or not, Mr. Duterte is following a strategy that leaders used throughout the Cold War: balancing between the powers by threatening to change loyalties. That strategy’s track record illuminates why Mr. Duterte’s seemingly reckless actions have borne him such fruit, and may offer a hint of his goals.