Eric Mosley tied the game for St. Bonaventure at 65-all with 3.1 seconds left. But Williams, a former high school quarterback, hurled his pass to Leslie, whose off-balance jumper hit the rim and fell through.
"We've tried it in practice, and it's only worked twice," Wolfpack coach Mark Gottfried said. "The odds were definitely against us."
The Bonnies' desperation inbounds pass was blocked as time expired, sealing N.C. State's win.
Scott Wood led the Wolfpack (7-4) with 20 points and Leslie scored 12.
Demetrius Conger and Andrew Nicholson each scored 16 for the Bonnies (5-5), and Mosley added 15.
The Bonnies scored the game's first nine points, but North Carolina State grabbed a 26-24 lead on a 3-pointer from Alex Johnson with 7:05 remaining in the half.
St. Bonaventure led 39-37 at halftime on Mosley's 3-pointer with 2.6 seconds left.
The Bonnies built a six-point lead in the second half, but the Wolfpack rallied to take the lead four different times in the last 3 minutes, including the final margin.
The teams had met just once before -- during St. Bonaventure's surprising run to the 1970 Final Four. The Bonnies beat the Wolfpack 80-68 in a Sweet 16 game.
Tuesday night marked the seventh time since 2000 that the Bonnies have hosted a neutral site game in Rochester. They are 1-6 in those games and have dropped six straight.
None was more heartbreaking than Tuesday's.
"They made a great play," Bonnies coach Mark Schmidt said. "We missed (intercepting) it, they got it and he made a great shot from behind the basket."
North Carolina State was coming off an 88-76 loss to top-ranked Syracuse on Saturday, a game the Wolfpack led by eight points at one juncture.
"I was concerned we wouldn't be emotionally ready tonight," Gottfried said. " But in the end, we had the right guys in the right spot."
St. Bonaventure shot 50 percent in the first half but just 29.2 percent in the final 20 minutes. The Wolfpack shot 43.8 percent in the first half and 42.3 percent in the second half.