Azarenka, also a winner in 2012 and 2016, had to come back from a set and a break down in the semi-final, and for a while looked like good preparation for the battle that Badosa provided.
But in the end Badosa prevailed 7-6 (7-5) 2-6 7-6 (7-2) after three hours, four minutes on court, securing only her second title in what was just her second final of the season while becoming the first Spanish woman to claim the title in Indian Wells.
A highly competitive start saw a combined total of nine break points go to waste in the first four games alone, and when Azarenka did finally lose a service game to go 4-3 down, she emphatically hit back at the first time of asking.
She had no option but to repeat that feat soon after when Badosa broke again to take a 6-5 lead, and she duly obliged to set up a tie-break.
But Badosa got the better of two-time grand slam champion Azarenka in the tie-break, despite the latter overturning a four-point deficit to go level at 5-5.
Azarenka appeared re-energised at the start of the second set, though, charging into a 3-0 lead inside 11 minutes, her level of intensity suddenly leagues ahead of her opponent's.
Badosa only showed brief glimpses of her ability and Azarenka had few issues levelling the match, her class on full display in the fifth game as she read a wide drop shot and replied with a sensational cross-court effort.
After such a colossal fight to get back on level terms it was perhaps to be expected that Azarenka would drop off a little early on in the decider, but a bad miss from Badosa allowed the Belarussian to recover from a break and she consolidated to tie the set at 2-2.
The pair continued to slog it out thereafter with neither woman giving an inch, Badosa's often-brutal power countered nicely by Azarenka's athleticism.
But Badosa was her own worst enemy as she overhit two shots to allow Azarenka to get what looked likely to be the decisive break, but the 32-year-old failed to serve out the match and, perhaps predictably, a tie-break ultimately beckoned.
Badosa's energy reserves suddenly looked far deeper than her opponent's as she moved her around the court with almost surgical precision, her eventual 7-2 win in the tie-break speaking to the ferocity she displayed to win the comfortably biggest title of her career to date.