Replying to Railways' 355, the hosts were bowled out for 309 as Dharmani (115) waged a lone battle.
At stumps, Railways had increased the lead to 169 runs, as they reached 123 for two in the remaining 29 overs.
Railways skipper Sanjay Bangar (43 not out) and all-rounder J P Yadav (64 not out) were at the crease at close.
Earlier, resuming at 159 for four, Punjab were reduced to 174 for six before Dharmani, who hit 12 fours and a six in his 246-ball knock, and Gagandeep Singh (17) added 68 runs for the seventh wicket.
But Yadav, who claimed five of the six wickets to fall in the day, to finish with figures of 5/83, struck again as he sent back Gagandeep and Vineet Sharma (10) in quick succession, and Harvinder Singh bowled Rajesh Sharma to reduce the hosts to 258 for nine.
However, Dharmani continued to wage a lone battle and added 51 runs for the last wicket with VRV Singh (14 not out) before he was castled by Yadav.
Railways' second innings also began on a disastrous note as they lost opener Amit Pagnis (0) without a run on the board and were reduced to 31 for two when Shreyas Khanolkar was run out on three.
But that brought Yadav to the crease and the strongly-built all-rounder proved that it was his day today.
He thrashed the Punjab bowlers at will as he hit seven fours and two sixes to remain unbeaten on 64 of just 62 balls.
Bangar, who had scored 79 runs in the first innings, continued from where he had left as he and Yadav added 92 runs for the unbroken third wicket.