The Italian became the first rider to rack up two victories this term after starting fifth on the grid, overtaking Miller with five laps to go in a fiercely competitive race.
The 24-year-old, who claimed his first MotoGP win in Qatar's curtain-raising race last month, made a strong start to fight his way into contention early on, entering the second spot with nine laps to go.
Bastianini then passed Miller and pulled clear of the Australian, who dropped into third as Alex Rins clinched a second consecutive podium finish, keeping him second in the drivers' championship standings.
The Gresini rider ended the race 2.058 seconds ahead of his nearest rival and tops the early-season riders' standings.
Elsewhere, Jorge Martin made a solid start from pole position but suffered a poor end to the race in which he dropped to fourth with eight laps to go, and to eighth by the time he saw the chequered flag.
Marc Marquez suffered a horrendous start in Texas, dropping as low as 17th in the early stages, but recovered somewhat to finish sixth, while Joan Mir and Francesco Bagnaia rounded out the top five.
World champion Fabio Quartararo, meanwhile, finished in seventh as he struggles to match his terrific early-season form from 2021, and Aleix Espargaro could only manage a 13th-placed finish, one week after his sensational maiden victory in Argentina.
1. Enea Bastianini (Gresini)
2. Alex Rins (Suzuki Ecstar) +2.058
3. Jack Miller (Ducati) +2.312
4. Joan Mir (Suzuki Ecstar) +3.975
5. Francesco Bagnaia (Ducati) +6.045
6. Marc Marquez (Repsol Honda) +6.617
7. Fabio Quartararo (Monster Energy Yamaha) +6.760
8. Jorge Martin (Pramac Racing) +8.441
9. Johann Zarco (Pramac Racing) +12.375
10. Maverick Vinales (Aprilia) +12.642
1. Enea Bastianini (Gresini) 61
2. Alex Rins (Suzuki Ecstar) 56
3. Aleix Espargaro (Aprilia) 50
4. Joan Mir (Suzuki Ecstar)) 46
5. Fabio Quartararo (Monster Energy Yamaha) 44
1. Suzuki Ecstar 102
2. Red Bull KTM 70
3. Aprilia 69
4. Gresini 61
5. Pramac Racing 59