sentences:  In 1819 the dispute was resolved with the signing of the Adams–Onís Treaty, in which the United States relinquished its claims to Texas and instead purchased Spanish Florida.In 1821 New Spain gained its independence from Spain and established the First Mexican Empire under the rule of Agustín de Iturbide, who had initially fought in the royal army against the insurgents in the independence from Spain.Independent Mexico was soon recognized by the United States.