India put into bat first raced to 196-6 powered by an opening stand of 75 off seven overs by Rohit Sharma (43) and Sikhar Dhawan (51) and it was only Perera's hat-trick in the penultimate over that prevented the home team from crossing the 200-run mark.
Sri Lanka were restricted to 127-9 with four batsmen being dismissed without scoring.
Perera dismissed Hardik Pandya (27), Suresh Raina (30) and Yuvraj Singh (0) off the fourth, fifth and sixth balls of the 19th over to somewhat pull back the Indian run scoring but a total close to 200 was good enough for India to defend on a wicket that helped the spinners.
Sri Lanka never recovered from losing Tillakaratne Dilshan to a first ball duck, Danushka Gunathilaka (2) and Seekkuge Prasanna (1) to be 16-3 in the fourth over.
Dinesh Chandimal (31) and Chamara Kapugedera (32) tried to regain the momentum in the Lankan innings with a half-century partnership but once they were dismissed off successive deliveries by left-arm spinner Ravindra Jadeja, the Lankan batting simply didn't have enough left in the tank to threaten the Indian total.
Milinda Siriwardana (28 n.o.) and Dasun Shanaka (27) tried valiantly to maintain the run chase but the effort proved too big a task against an Indian team who was fuelled up after their defeat in the first T20 at Pune three days ago.
Dhawan took the man of the match award for his 25-ball half century that set India heading towards a match winning total.
The third and decisive T20I will be played on Sunday at Visakhapatnam.