Captain Tillakaratne Dilshan led from the front with 87 and Thisara Perera hit his first half-century in a one-dayer to lead Sri Lanka to a superb five-wicket win over South Africa Friday. The visitors, chasing South Africa's 299 for seven, reached 304 for five with eight balls to spare to cut their series deficit to 3-1 with one match remaining. Opener Dilshan's run-a-ball innings started Sri Lanka's assault and left-hander Perera finished off the home team by smashing 69 not out off 44 deliveries. The 22-year-old Perera struck three fours and five sixes and was given valuable support by Dinesh Chandimal (59). Dilshan, who went into the match with only 33 runs in the series, put his bad form behind him by clubbing nine fours and two sixes as he shared a second-wicket stand of 83 with Kumar Sangakkara (32). The skipper's dismissal in the 29th over set Sri Lanka back but Perera took the game by the scruff of the neck and secured victory with a huge straight six off spinner JP Duminy. Left-arm seamer Lonwabo Tsotsobe was the stand-out bowler for South Africa with three for 51. Earlier, South Africa's big total was set up by captain AB de Villiers who blazed his way to 96 off 76 balls. De Villiers cracked eight fours and three sixes as he chalked up his 28th half-century in a one-dayer. Alviro Petersen (37) and Graeme Smith put on 84 for the first wicket after the hosts had won the toss before Smith and De Villiers shared a stand of 87 for the next wicket. Smith fell for 68, his 45th half-century in a one-dayer, and then De Villiers walked across his stumps and was bowled by seamer Perera. The fifth and final match is in Johannesburg Sunday.