The 21-year-old Farhat hit a polished 101 as Pakistan, replying to India's 287, reached 265 for three by tea on the second day with captain Inzamam-ul-Haq unbeaten on 65 and Yousuf Youhana on 33 on Tuesday.
Farhat hit 14 boundaries during his 266-minute stay at the crease before he edged Laxmipathy Balaji to wicketkeeper Parthiv Patel.
Inzamam appeared in dangerous form, hitting eight boundaries to build on Farhat's good work. The fourth-wicket pair of Inzamam and Youhana has so far added 60 runs.
Pakistan, hoping to level the three-match series after losing the first Test by an innings last week, need 23 more to take the lead with seven wickets in hand.
Farhat, who registered his maiden hundred against South Africa at Faisalabad last year, hit leg-spinner Anil Kumble for three boundaries to move into the nervous 90s.
Farhat survived a confident appeal for a catch at the wicket off Balaji on 99 before taking a quick single in the same over to complete his century.
Pakistan, resuming at 61 for one, progressed steadily to 95 before seamer Ajit Agarkar struck in his first over of the day.
Yasir Hameed played a rash shot outside the off stump and was smartly snapped up at first slip by Rahul Dravid after making 19.
Farhat was lucky to reach 50 when he hooked Irfan Pathan's bouncer in the air and Agarkar dived valiantly, only to see the ball drop short and cross the boundary.
Inzamam, who made 77 and 0 in the first Test, hit two scorching fours off Agarkar and helped Farhat add 110 runs for the third wicket which consolidated home team's position.
Left hander Yuvraj Singh had saved India's blushes on day one with a fighting 112 after lanky Pakistan seamer Umar Gul wrecked the top order with career best figures of 5-31.