Mahendra Singh Dhoni's team looked up against it when Sri Lanka posted an imposing total of 333-5 after being put into bat.
But Kohli smashed 144 from 120 balls and Karthik blasted 106 not out from only 81 balls to lead India to victory with one over to spare.
India were struggling at 62-3 in the 13th over and then 110-4 in the 21st over before Kohli and Karthik came to the rescue.
Kohli hit 11 fours and three sixes, while Karthik notched up 12 fours and two sixes as he and Dhoni, who scored 18 not out, helped India finish on 337-5.
India play their second warm-up game against Australia on June 4 in Cardiff before opening their Champions Trophy campaign against South Africa at the same venue two days later.
buy flexeril online buy flexeril online no prescription
Kusal Perera and Tillekaratne Dilshan had caused plenty of problems for the Indian bowling attack in a blistering start for the Sri Lanka openers.
Dilshan hit nine fours and one six in his 84, while Perera scored 82 off 94 balls, including three sixes.
That pair ad