Elgin ( EL-jin) is a city in Cook and Kane counties in the northern part of the U.S. state of Illinois. Elgin is located 35 mi (56 km) northwest of Chicago, along the Fox River. As of the 2020 Census, the city had a population of 114,797, the seventh-largest city in Illinois.