Pakistan, hoping to level the three-match series after losing the first Test by an innings last week, ended the ill-tempered second day's play at 355 for three to take a 68-run lead with seven wickets in hand.
India were shot out for 287 on the first day after electing to bat on a greenish wicket at the Gaddafi stadium.
Inzamam, unbeaten on 118 at close, added 110 for the third wicket with Farhat and 150 for the undefeated fourth with Yousuf Youhana, who returned unconquered on 62 on Tuesday.
Farhat hit 101, his second Test century, before his illustrious captain took over to compile his 19th Test hundred and the first against India in four matches.
Farhat hit 14 boundaries during his 266-minute stay at the crease before he edged Laxmipathy Balaji to wicketkeeper Parthiv Patel.
Inzamam, who made 77 and 0 in the first Test at Multan, was in terrific form, smashing 14 boundaries during the eventful afternoon's session.
India's bowlers showed their displeasure when West Indian umpire Steve Bucknor turned down leg-before appeals against both Youhana and Inzamam off the same bowler, Irfan Pathan.
Youhana was then on 35, while Inzamam was on 65.
Youhana survived another close call when television replays showed leg-spinner Anil Kumble's spinning ball catch the edge before lodging in Patel's gloves, but Australian umpire Simon Taufel was unmoved.
As tempered flared on the field, the Indians had another reason to feel frustrated when Bucknor rejected a confident appeal by Balaji for a catch at the wicket off Inzamam.
An unruffled Inzamam swept Kumble for his 12th boundary to reach his century.
In the morning, Pakistan progressed steadily to 95 after resuming at 61 for one 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 Pathan's bouncer in the air and Agarkar dived valiantly, only to see the ball drop short and cross the boundary.
Pakistan reached 145 for two at lunch and soon after the break Farhat launched an attack on Kumble, hitting three boundaries to race into 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.
India took the second new ball just before tea with Pakistan's total at 265 for three, but Inzamam and Youhana batted steadily to help their team surpass India's moderate score.