Notts leg-spinner Imran Tahir led the recovery with 7-112 as Somerset were all out for 437 - a lead of 36.
Resuming on 244-3, South Africa international Tahir claimed six of the seven Somerset wickets to fall on a scorching day - including Trescothick, who added 101 to his overnight 117.
Notts lost Steven Mullaney and Michael Lumb early, before closing on 58-2.
Trescothick, who equalled Somerset's record for the most first-class centuries with his 49th on Monday, was in wonderful form once again despite stifling temperatures.
The 40-year-old brought up his double century off 323 balls with a trademark cover drive off Samit Patel - his 31st boundary - before he was the last man to go, chipping Tahir to cover.
Somerset looked set for a much bigger lead as Trescothick and Jim Allenby's hundred partnership took them to 379-4 and within 22 of the hosts.
But once Allenby was bowled by Patel for 63, Tahir tore through the rest of the batting order as Somerset lost their last five wickets for 37.
The procession of afternoon wickets continued in Nottinghamshire's second innings as Craig Overton pinned first-innings centurion Mullaney lbw and Allenby bowled Lumb without scoring in the next over.
Jake Libby and Brendan Taylor batted out the final hour to give Notts a lead of 22 at stumps.
Somerset opener Marcus Trescothick hit a superb 218 before Nottinghamshire fought back at Trent Bridge.