Off spinner Perera was named man of the match after taking six for 70 in the second innings for a match return of 10 for 99 - his first 10-wicket haul in tests.
His previous best return in an innings was five for 69 against South Africa, while his top match haul was his eight for 129 from the same test.
Perera also became the fastest Sri Lankan bowler to take 50 test wickets, in his 11th game.
After winning the toss, Sri Lanka made 281 in its first innings with Kusal Mendis top scoring with 86.
Australia was bowled out for 106, with Sri Lanka helped by a hat-trick by left-arm spinner Rangana Herath.
Sri Lanka made 237 in its second innings, with Perera also starring with the bat through a top score of 64.
Sri Lanka captain Angelo Mathews was elated after the series win, which came after losing five out of six series in the past two years.
He said the result was possible because the team and the management backed him in adversity.
"They backed. They said we will get a bit of stick and we'll lose a few games but if we do our processes right, along the way we'll win a few games," Mathews said. "To beat the No. 1 team is very satisfying."
Australia captain Steve Smith said his team had been outplayed.
"The guys are a bit down at the moment, it's been a tough series so far. We've been outplayed in both test matches," Smith said.
He said his batsmen had paid heavily for their inability to read Sri Lanka's spinners, failing to tell which balls would spin from those that skidded on.
"We've still got plenty to play for in Colombo. We've got to try and prove to ourselves and the public that we can play in these conditions," Smith said.
Australia had arrived in Sri Lanka wanting to turn around a series of poor performances in Asia.
Since winning its last three-match series in Sri Lanka 1-0 five years ago, Australia lost series against Pakistan in the United Arab Emirates and in India 2-0 and 4-0 respectively.
Left-arm fast bowler Mitchell Starc stood out for Australia bowling in unfavorable conditions, taking a career-best haul of 11 wickets.
Resuming the third day at 25 for three, Australia lost overnight batsman David Warner for 41 with the total 61. He was trapped lbw by Perera.
Captain Smith (30) was caught by Kusal Mendis off Perera and Mitchell Marsh (18) was ruled lbw as he offered no stroke to spinner Lakshan Sandakan.
Australia was unable to recover from that position facing a rampant Sri Lankan spin pair of Perera and Herath.
Sri Lanka won the first test by 106 runs in Pallekele last week. The third test will begin in Colombo next Saturday.
- AAP