 He later served in the Mexican–American War, commanding the 2nd Battalion, Mississippi Rifles with the rank of lieutenant colonel as of February 22, 1848.That July he was mustered out of the volunteer service.Anderson later entered politics, serving in the Mississippi House of Representatives and befriending Jefferson Davis, a fellow former Mississippi volunteer officer in the U.S. Army.