MANILA—President Rodrigo Duterte aims to upend the delicate geopolitics of the South China Sea during a state visit to Beijing this week, gambling that pulling away from the U.S.—the Philippines’ longtime military ally—will reset the strategic calculus in Southeast Asia in his poor country’s favor.

China and the Philippines have been at loggerheads since 2012 when Beijing took control of Scarborough Shoal, a rich fishing area in the South China Sea, 125 miles west of the former U.S. Navy base at Subic Bay.

That...