Alviro Petersen scored 53 runs in the session to reach 158 not out at lunch with Lancashire 404 for 5.
Rayner struck with his first ball of the day, ending a stand of 128 in 38 overs by Petersen and Steven Croft when Croft was caught behind off a mis-timed reverse sweep for 46.
James Fuller pulled off an athletic catch at backward square-leg off a full-blooded sweep by Karl Brown (21) after he and Petersen had added 46 for the fifth wicket.
But it was hard going for the Middlesex seamers on a benign pitch with Petersen timing the ball impeccably, particularly through his strong areas on the off side. So far the 35-year-old has faced 255 balls and hit just eight fours while Liam Livingstone struck successive boundaries off James Franklin in the penultimate over before lunch to take Lancashire past 400.