Two-time champion Alonso crossed the line just 0.053 seconds ahead of the Red Bull driver to secure the final podium spot at Interlagos, as Aston Martin returned to the rostrum for the first time since Zandvoort.
The battling duo injected late drama into a largely tepid affair won by Max Verstappen. Ninth-starting Perez dived up the inside of the AMR23 into Turn 1 on lap 70 of 71.
But on the final tour, Alonso - who had lined up fourth on the grid - made the Mexican move off-line to defend through the opening corners and then deployed DRS to dart round the outside into Turn 4.
Alonso then took a wide line into the last corner to aid his exit and uphill run to the flag but in the slipstream, Perez closed to tee up a spectacular finish.
With Alonso narrowly holding on, Aston team principal Krack credited his experienced driver for taking "unconventional" routes.
He said: "It was an interesting fight in the last couple of laps. Obviously, the closer you go to the end of the race, the more exciting it gets… it was an interesting fight.
"You could see that we took some lines that were maybe a bit unconventional, let's say. But Sergio behind was told to do the same, interestingly.
"So basically, you could really see the interesting dynamics that develop there - everybody tried to manage his tyres to be strong in the parts where you can overtake. And this was quite interesting.
"You saw the huge experience, how [Alonso] managed his game there against someone that on paper has a quicker car."
Krack added that there were several places around the lap where Alonso had varied his approach in a bid to look after the Pirelli tyres, which drivers complained were degrading faster than normal throughout the Brazil weekend.
Asked whether the thought Alonso would regain the position after Perez dived passed on the penultimate lap, Krack continued: "You never know how much juice everybody has in his tank so this is really dictating how it's going to end.
"Then, going for the last time down the back straight to Turn 4, I think Fernando prepared it really well from the exit of Turn 1 and Turn 2, and managed to overtake."
Aston Martin team-mate Lance Stroll finished fifth.