A dispute with Great Britain as to who should control the Pacific Northwest was settled in 1846 with the signing of the Oregon Treaty. Great Britain got Vancouver Island and everything above the 49th parallel. The U.S.A. got everything below, to the California border (the U.S. meanwhile, was also engaged in a war with Mexico over claims to California).
In 1847 the infamous Whitman Massacre occurred, and though the pioneers of the Willamette Valley had already established their own provisional government, the events in Walla Walla forced the hand of Congress, which, on August 13, 1848, officially established the Oregon Territory.
President James K. Polk appointed Joseph Lane governor of the newly created Oregon Territory. One of his first duties when he arrived at Oregon City nearly a year later was to precipitate the Whitman Massacre trial.