Explaination: This stratagem has two applications: the first is the more obvious. Avoid a two-front war by making peace with everybody else before you go to war against an opponent. Additionally, if you have two battles to fight, it's wiser first to fight the one that is near at hand. But to do this, you must try to gain at least a temporary peace with the less emergent battle.
Related story
In 270 BC, King Zhaoxiang was actively endeavouring to campaign against the state of Qi , the eastern most part of China, mostly utilizing the mighty Qin army to his own benefit. King Zhaoxiang's visitor advisor, Fan Ju , adviced King Zhaoxiang to abandon these fruitless campaigns and shifted the Qin policy to maintain good diplomatic relationships with distant states such as Qi, and concentrate forces against its direct neighbours of Han and Wei, the so called "Befriend A Distant Enemy To Attack One Nearby." policy.
Under this policy, Han and Wei found themselves plagued with decades of Qin advances and saw their land lost to Qin in chunks followed by hundreds of thousands of soldiers killed. The Qin territory had advanced deep across the east shore of the Yellow River and beyond. The very existence of Han and Wei was merely a strategic balancing buffer zone between Qin in the west, Zhao in the north, Qi in the east, and Chu in the south. Their troops were used as spearheads pointing west by the alliance of the eastern states against Qin, as well as the same puppet spearheads, but pointing east, aiding Qin advances mostly against Chu. Had Qin not worried about a united retaliation against herself from these three states (which seemed unlikely since these three states were also busy struggling with each other), Han and Wei had ended their royal houses decades before their eventual conquest by Qin.