Kyle Waldrop (1-0), the Bucs' fifth pitcher, blanked the Blue Jays in the top of the 10th.
It was the Pirates' second straight walk-off win, and their fourth straight overall, improving their record to 8-10. Toronto fell to 7-10-1.
A record crowd of 8,439 at McKechnie Field saw an impressive outing by starter James McDonald.
McDonald recovered from a rough start to become the first Pirates pitcher this spring to work into the sixth inning.
Four of Toronto's first five batters reached base -- including Emilio Bonifacio on an infield single which third baseman Pedro Alvarez threw wildly for an error that scored one run. Adam Lind followed soon after with an RBI single.
From that point on, McDonald retired 14 of 16 batters until leaving following a one-out single in the sixth by Lind -- who eventually scored on Mike Nickeas' single off reliever Mark Melancon to give Toronto a 3-1 lead. McDonald allowed five hits and three runs in 5 1/3 innings, with two walks and five strikeouts.
Buehrle allowed four hits, walked one and did not have a strikeout.
The Pirates had cut the deficit to 2-1 in the third when Starling Marte tripled and scored on Andrew McCutchen's single.
With the Bucs trailing, 4-1, in the eighth, Josh Harrison made it 4-2 with an RBI single off Neil Wagner, and Pittsburgh tied it with two runs in the bottom of the ninth.
Felix Pie led off the ninth with a home run off Tyson Brummett, Toronto's sixth pitcher. Pinch-hitter Lucas May walked and pinch-runner Dan Grovatt advanced to second on Alex Presley's grounder before scoring on a two-out ground-rule double by Harrison, his fourth consecutive hit in the last two games, to make it 4-4.
Up next: The Pirates travel to Clearwater on Thursday for their second of two spring games against the Phillies, who had blanked them on one hit on March 4. Kyle McPherson will make a start important for his rotation candidacy, coming off two outings in which he allowed a combined eight runs in 5 2/3 innings.