sentences:  U.S.–Mexico relations grew out of the earlier relations between the fledgling nation of the United States and the Spanish Empire and its viceroyalty of New Spain.Modern Mexico formed the core area of the Viceroyalty of New Spain at the time the United States gained independence from Great Britain in the American Revolutionary War (1775–1783).Spain had served as an ally to the American colonists in that war.