Sussex 174 (Haines 41, Potts 3-43, Conners 3-47) and 513 for 3 (Haines 243, Pujara 201*) drew with Derbyshire 505 for 8 dec (Masood 239, Madsen 111, Thomson 52)
They shared a stand of 351 in 119 overs, a Sussex record for any wicket against Derbyshire and other milestones were passed before the teams shook hands.
Haines batted for just short of 11 hours for 243 while Pujara was unbeaten on 201 from 387 balls as Sussex closed on 515 for 3 ,180 ahead after following on 331 behind.
It was the first time in a Derbyshire match that three players have scored double hundreds after Shan Masood made 239 for the home side.
This was only the third time it has happened on any ground in Britain, the other two were both at Northampton, and the feat has only been achieved on 11 occasions in the history of first-class cricket.
The pair looked certain to bat through the day but Haines chipped Nick Potts to midwicket shortly before the close and was congratulated by all of the Derbyshire players before he walked off.
Derbyshire's hopes of seeing an Easter parade of wickets rested with the second new ball which was only 16 overs old and for the first hour, Haines and Pujara had to fight hard to survive.
Sam Conners beat the bat several times while Suranga Lakmal delivered his best spell of the match from the City end.
The Sri Lankan paceman had a fascinating duel with Pujara who almost lost his wicket on 64 when a fine leg glance bounced just in front of Brooke Guest diving across to his left.
Only 36 runs came in just over an hour but Haines pulled the off-spin of Wayne Madsen to the ropes to wipe out that arrears before Pujara cut Potts to the boundary to bring up the 200 stand in 71 overs.
Haines was reprieved on 194 when he edged a cut at Alex Thomson but Madsen at slip could not hold on to a sharp head-high chance.
He made the most of it by completing the first double century of his career by driving the last ball of the morning from Thomson to the cover boundary for his 20th four.
It was a remarkable display of concentration and intent from the 23-year-old and he and Pujara moved serenely on after lunch.
Pujara clipped Potts wide of mid-on for his 14th four in the first over of the afternoon session to reach his 100, which was his first in 27 months.
Derbyshire kept rotating their bowlers but there was no sign of a breakthrough until Pujara, on 130, drove a swirling catch to long-on where Billy Godleman failed to cling on.
Haines was missed for a third time in the next over when he cut Leus du Plooy hard to slip but Madsen again failed to take a sharp chance.
Pujara completed his 150 from 326 balls and the 300 stand was posted in 108 overs before the pair walked off at tea with Sussex 123 runs ahead.
Another record fell in the first over of the final session as the pair passed the previous Sussex highest stand for any wicket against Derbyshire of 310 set by Ed Joyce and Luke Wells at Derby in 2016.
Derbyshire's chances of victory had long gone when Haines's marathon finally ended, but Pujara completed his double hundred on a day to remember for Sussex cricket.