The XYZ Affair brought the United States to the brink of war with?
The answer to this question is France. The XYZ Affair was an incident that occurred in 1797 and almost led to a war with France, which had been the Americans' most important ally in the Revolutionary War.
By this time, France and England were at war. The US was trying to remain neutral. President Adams sent envoys to the French to try to reach an understanding with them. But the French demanded money (in the form of a large loan and a bribe) just to allow the envoys to talk to the foreign minister. The Americans balked at the demand and conflict erupted between the two countries (though it did not lead to war).