Elgin is a city in northern Illinois located roughly 40 mi (64 km) northwest of Chicago on the Fox River. Most of Elgin lies within Kane County, Illinois, with a portion in Cook County, Illinois. As of the 2010 census, the city had a total population of 108,188, making it the eighth-largest city in Illinois and the 241st largest city in the United States