Aston Martin's pace was an unknown factor heading into qualifying after Alonso and team-mate Lance Stroll finished 12th and 14th respectively in final practice.
Alonso also barely scraped by in Q1, with Stroll even eliminated in 18th. But in Q2 the two-time world champion came to the fore with third, under three tenths shy of pacesetter Max Verstappen.
In a disrupted Q3 shootout the Spaniard then grabbed a second starting spot alongside Red Bull's polesitter Sergio Perez.
According to Alonso, his "messy FP3" was caused by set-up experiments, but on a more familiar set-up his AMR23 "came alive" in qualifying.
"It was a good qualifying, I think FP3 was a little bit messy for us," he explained.
"We tried different set-ups and they didn't work, but the team obviously put the car in a more known place after the first four races and the car came alive in qualifying.
"So yeah, extremely happy with P2. Obviously, first row of the grid, let's see what we can do."
Qualifying on the repaved Miami International Autodrome threw up some surprising results, with Verstappen stuck down in ninth after making a mistake on his only timed lap.
Charles Leclerc's crash then prevented anyone from setting another time as he brought out the red flag with not enough time on the clock to restart the session.
It meant his team-mate Sainz was locked into third, with Haas' surprising Kevin Magnussen set to join him on the second row.
But amid complaints over Miami's low-grip track, Alonso said he "enjoyed every lap" of its challenging layout.
"I did enjoy every lap, it was so enjoyable to drive," he beamed. "Especially the low-speed corners here are quite tricky.
"You go quite close to the walls between Turn 11 and 16, so you need to have that confidence in the car to really attack qualifying. And I had the confidence today, so I was very pleased.
"It was difficult the whole weekend. It is a very narrow racing line that we are cleaning, and it gets quite grippy, but offline it gets quite slippery."