Gavin Hume was the hero for the visitors, the South African going over in the 70th minute to set up a match-winning conversion from Wales fly-half James Hook.
Toulouse fly-half Luke McAlister had a chance to reclaim the lead five minutes later but his penalty attempt hit a post and Perpignan held on for the win, which sees them move up to sixth in the Top 14 table.
McAlister had earlier successfully converted six penalties to give the hosts an 18-12 lead with 10 minutes remaining.
But Hume's try turned the match on its head, giving Toulouse coach Guy Noves little to celebrate in his 1,000th match associated with the club.
The result see Toulouse remain in second place, six points behind leaders Toulon who host Montpellier on Saturday.