Dharmani, who scored his 17th Ranji century, was instrumental in Punjab gaining the lead as he held fort at one end after the hosts resumed at 221 for seven.
He also completed 5,000 runs in process, becoming only the second batsman from Punjab to reach the milestone.
In their second innings, Uttar Pradesh, who had made 269 in the first knock, were 206 for the loss of two wickets for a lead of 137 runs. Jyoti P Yadav was batting on a strong 82 while Suresh Raina was on 37 at close.
Earlier, the hosts added 87 runs before being bowled out. Dharmani and the other overnight batsman Gagandeep added 29 runs before Gagandeep (17) was bowled by RP Singh. New man in VRV Singh was out off the next delivery of Singh without any addition to the total.
Rajesh Sharma (19) and Dharmani (125) added 58 runs before Dharmani was caught at fine leg by Mohd Amir Khan off Srivastava with the total reading 308.
Uttar Pradesh commenced their second innings on a confident note with openers Rohit Parkash and Jyoti Yadav making a good start. The opening wicket partnership was broken by VRV Singh when he dismissed Rohit for 62 (10x4).
Star Indian batsman Mohd Kaif (12), however, disappointed being caught in the gully off A Uniyal when the total was 151.