At first, the United States tried to remain neutral. However, it became increasingly difficult as the war intensified. Both Britain and France began to interfere with American shipping, and they each tried to recruit the United States as an ally. In 1797, the United States government signed the Jay Treaty with Britain. This treaty improved relations between the two countries, but it also angered France. In 1798, the United States and France went to war. The war lasted for about two years, and it ended with a stalemate.