The Aprilia rider came from seventh on the grid to win a dramatic sprint in which Marco Bezzecchi crashed out, and Marc Marquez also slid off the track, taking pole-sitter Fabio Di Giannantonio with him.
Bezzecchi, who led Martin by 11 points in the riders' standings heading into the weekend, was running in second place before crashing.
Martin edged one point ahead of his teammate heading into Sunday's main race at the Circuit of the Americas, which is hosting a MotoGP race for the first time.
Reigning world champion Marquez, starting from sixth place, crashed on the opening lap and took out Di Giannantonio.
Bagnaia led for most of the sprint but failed to close it out as Martin, the 2024 world champion, scythed his way through the field.
Bezzecchi, who has won the last four MotoGP main races dating back to last season, failed to finish for the second time in three sprint races this campaign.
Spanish youngster Pedro Acosta stayed out of trouble to finish third.
