Miller led the from the start until five laps from the flag when Bastianini made his move at turn 12.
The Italian stretched his lead almost immediately to over half a second leaving the Australian to battle with Suzuki’s Alex Rins for second.
Rins got the better of Miller on the final lap for second and now lies second in the title race ,five points behind Bastianini on the Gresini Ducati who was over two seconds clear of the Spaniard at the chequered flag. 2020 champion Joan Mir was fourth on the Suzuki with Pecco Bagnaia fifth on the second factory Ducati.
Seven-time winner in America, Marc Marquez, on the Repsol Honda was last away after a terrible start but fought his way through to sixth by the flag holding off reigning champion Fabio Quartararo.
“It was a fantastic day,” said Bastianini.
“First part of the race was really hard then in the middle of the race when I see Rins very close to me and trying to overtake many times I think now it’s time to push because the temperature of the front tyre was too high.
“In the end I push like mad and it was incredible to win in America.”
British star Jake Dixon claimed his maiden world championship podium in Moto2 for the Gas Gas Aspar team, finishing third behind Ai Ogura and race winner, Italian Elf Marc VDS rider, Tony Arbolino.
An emotional Dixon said: “I know it is third position but I’ve worked so hard for this.
“It’s been a tough three years but finally I’m able to show my potential.
“To be honest from ten laps to go I just rolled out of it.
“I wasn’t taking any risks. Maybe I could have fought for second but today wasn’t the day.”
Jaume Masia was the winner of the Moto3 race.