On January 16, 1847, Commodore Stockton appointed Frémont military governor of California following the Treaty of Cahuenga, which ended the Mexican-American War in California. However, U.S. Army Brigadier General Stephen Watts Kearny, who outranked Frémont (and who arguably had the same rank as Stockton, one star) and said he had orders from the President and Secretary of War to serve as governor, asked Frémont to give up the governorship, which he stubbornly refused to do for a time. Kearny gave Frémont several opportunities to retract his position. When they arrived at Fort Leavenworth in August 1847, Kearny arrested Frémont and brought him to Washington, D.C. for court martial, where he was convicted of mutiny. President James K. Polk approved of the decision of the court, but quickly commuted his sentence of dishonorable discharge in light of his service in the war. Frémont, however, considered his conviction an injustice and a dishonor, and wrote to Polk in February 1848 that he would resign from the army unless the President overturned his conviction. One month later, having received no reply from Polk, Frémont resigned his commission and settled in California.