India, chasing 231 to go 2-0 up in the series, were cruising at 109 for no loss in the 16th over when Dananjaya struck, dismissing Rohit Sharma for 54.
That was just the appetizer, however, as it was in his next over that the spinner would inject fresh drama into the game and life into the gloomy stands.
Dananjaya slipped in three googlies to dismiss Kedar Jadhav, Kohli and KL Rahul in the space of five balls, bringing his side back into the match.
“You have to give credit to a guy who bowled an outstanding spell,” Kohli said afterwards, dismissing suggestions that rejigging the batting order led to their collapse.
“If I had gone at number three, I still would have missed the ball, because he was bowling that well in that spell,” the India captain, who batted at number five, said.
“The batting order did not really matter.”
Dananjaya is another product of Sri Lanka’s seemingly endless reserves of special bowlers, an off-spinner who can also bowl leg-spin, googly, ‘doosra’, and even the carrom ball.
His full range of tricks was on exhibition on Thursday against a team traditionally very comfortable against spin.
The Indians did not help their own cause by staying on the back foot as Dananjaya curled googlies through their gates.
“I realised my off-spin was working better, I kept using all the variations in my first eight-over spell,” Dananjaya said after collecting the man-of-the-match trophy.
Kohli said his team now had a better idea about what to expect from the bowler.
“We thought he was the off-spinner bowling an odd leg-break, but he picks up four wickets on googlies,” a bemused Kohli said.
“It’s difficult when you have not seen the guy at all. He has not played us before. But now we saw how the ball was coming out of his hand,” he added.
The teams meet again on Sunday with India, who whitewashed Sri Lanka in the preceding test series, hoping to clinch the five-match series with two one-dayers to go.
(Reporting by Amlan Chakraborty in New Delhi; editing by Peter Rutherford)