Elgin is a city in the U.S. state of Texas. It is in both Bastrop and Travis counties. In 2020, 9,784 people live in Elgin.