Scorecard I Match in Pics
Dravid batted nearly the entire first day to finish at unbeaten 177, while Dhoni made a splendid 110 before he was out three overs before stumps.
The elegant right-handed Dravid, also known as "Wall" for his temperament, completed 11,000 runs in Test matches and hit 26 boundaries and a straight six in yet another 251-ball knock.
It was a remarkable turnaround by Dravid and Dhoni after paceman Chanaka Welegedara's triple strike had left the home team reeling at 32-4 inside the first hour.
Dravid featured in two productive partnerships which gave India an early initiative in the three-Test series. He added 224 runs for the sixth wicket with Dhoni before Dhamika Prasad had the India skipper caught behind just before close. Dhoni hit 10 boundaries and a six in his first Test century at home and faced 159 deliveries.
Dravid first resurrected the innings with a 125-run stand with Yuvraj Singh (68), and then featured in a double-century stand with his captain.
Earlier, Welegedara caused major concerns for the hosts with his opening burst of three wickets, including Sachin Tendulkar for four, after Dhoni won the toss and elected to bat.
The 28-year-old swing bowler clean bowled Gautam Gambhir with the total at 14 and then had two wickets in the sixth over. He had Virender Sehwag (16) lbw with a ball that pitched on middle stump and then bowled Tendulkar (4) between bat and pad.
Tendulkar, celebrating his 20th anniversary in Test cricket, lasted only three deliveries.
Prasad had VVS Laxman bowled without scoring in the seventh over to have India reeling at 32 for four. That brought Yuvraj and Dravid together and both batsmen attacked the Sri Lankan bowlers.
The gamble paid off as they struck some delightful boundaries on both sides of the wicket in a powerful partnership and kept the scoring rate well over four runs an over.
Muttiah Muralitharan finally broke the threatening stand when he lured Yuvraj with a slow flighted delivery and offered a tame catch to Tillakaratne Dilshan in the covers.
Yuvraj hit 13 boundaries in his 93-ball innings before his concentration lapse.
Dravid - ignored for the One-day series against Australia - pumped his fist in the air when he completed his 27th Test century with a single off left-arm spinner Rangana Herath soon after tea.
Dhoni raised his hundred when he came down the wicket to Herath's flighted delivery and drove past the fielder at covers for his ninth boundary of the innings.
Welegedara, playing only his second Test match and first in almost two years, was the pick of Sri Lankan bowlers with 3-75.
India left out paceman Shanthakumaran Sreesanth and will rely on Zaheer Khan to lead the attack on his comeback from injury. Sri Lanka left spinner Ajantha Mendis out of its starting XI