Elgin is a city in Cook and Kane counties in the northern part of the U.S. state of Illinois. Located roughly 35 mi northwest of Chicago, it lies along the Fox River. As of the 2020 Census, the city had a population of 114,797, making it the sixth-largest city in Illinois.