Stokes smashed 128 runs after Ali, who had been unbeaten on 99 overnight, made 117 as England compiled a commanding total of 537 before India's openers responded with an unbeaten stand of 63 in the final session.
Joe Root (124) had notched up a century on the opening day to lay a solid foundation for the middle-order batsmen at Rajkot's Saurashtra Cricket Association ground.
India made a cautious start to their innings with Murali Vijay (25 not out) and Gautam Gambhir (28 not out) at the crease when stumps were called.
The day belonged to England's batsmen who made India toil on an easy-paced track after captain Alastair Cook had elected to bat first.
Although the tourists lost a succession of tailenders in the period immediately after lunch, Stokes stayed put to help England post their third highest total on Indian soil.
Stokes, who had three ducks in three previous Test innings against India, hit 13 fours and two sixes on way to his fourth ton in the longest format of the game.
India's bowlers struggled in the heat and grime, with top-ranked spinner Ravichandran Ashwin conceding 167 runs while taking just two wickets.
England showed their aggressive intent in the morning session, hammering 139 runs while losing two wickets including that of Ali who was bowled by Mohammed Shami (2-65).
Jonny Bairstow, the highest Test run-scorer this year, made 46 and shared a brisk 99-run partnership for the sixth wicket with Stokes before also falling to Shami.
At least five dropped catches and some sloppy fielding underlined a miserable day for the Indians before their home fans.
Top-ranked India have won 12 and drawn one of their last 13 Tests at home since England sealed a historic 2-1 victory in Kolkata in 2012.
Stokes was dropped twice in his sixties by wicketkeeper Wriddhiman Saha with Umesh Yadav (2-112) being the unlucky bowler on both occasions.
The Indians took the new ball in the morning after England resumed at 311 for 4, but failed to get an immediate breakthrough.
Ali reached his century off the third ball of the day from Shami who seemed to have recovered from the cramps he suffered on the opening day.
The spinning all-rounder singled out Yadav for special punishment, taking three fours in four balls off the paceman.
Stokes chipped in before Shami broke their 62-run stand with the wicket of Ali who saw his off-stump cartwheel away in spectacular fashion after misjudging the line and not playing a shot.
England's total was the highest by a visiting team in India since the West Indies made 590 at Mumbai in November 2011.
The previous instance when three batsmen from a visiting team scored centuries in the same innings in India was in 2008-09 when Sri Lanka toured the country.
Original source: Stokes, Ali star as England post commanding total