With the ratification of the Adams-Onís Treaty, Spain officially renounced a claim to the Oregon Country on February 22, 1821.
(The treaty was originally signed two years earlier to the day, on February 22, 1819, by United States Secretary of State John Quincy Adams and Spanish minister Luis de Onís, but Spain took their sweet time to ratify it.)
The treaty was largely about establishing the border of New Spain and U.S. territory that was part of the Louisiana Purchase. The U.S. got Florida, Spain got Texas (for the time being), and Spain agreed to relinquish any claim to Oregon north of the 42nd parallel – i.e. the northern border of California.