Lewis Guy raced on to Paul McGowan's slide-rule pass to open the scoring after 16 minutes and Steven Thompson doubled the hosts' lead on the half-hour mark.
A wonderful individual effort from McGowan stretched the Paisley side's advantage to three before Kenny McLean added a fourth from the penalty spot.
The visitors pulled one back through Michael Moffat six minutes before the break but the Scottish Premier League side added a fifth through Gary Teale in the second half.
Buddies manager Danny Lennon made three changes to his line-up - David Barron, Gary Teale and Lewis Guy were all handed starting berths while David Van Zanten, Dougie Imrie and Sam Parkin dropped to the bench.
The hosts made a bright start and dominated possession during the opening five minutes of the match.
The first chance came after seven minutes and fell to Thompson. The striker linked with Jim Goodwin before flashing a powerful effort at goal which Brown in the Ayr goal was forced to parry round the post.
Ayr were forced into an early change when Martyn Campbell hobbled off to be replaced by Marc Twaddle.
Samson had to tip David Sinclair's effort over the crossbar after 15 minutes, however the visitors were punished from the resulting corner.
McLean cleared Michael McGowan's delivery and McGowan released Guy, who raced through on goal before dispatching the ball beyond Brown.
Following the opener, Anthony Marenghi picked up the first booking of the match for dissent.
Guy passed up a good opportunity to double his lead two minutes later when he headed McGowan's corner over the top.
Darren Brownlie's brave challenge prevented Thompson taking advantage from Teale's dangerous delivery on 23 minutes, but the former Rangers and Dundee United man was celebrating 30 seconds later, leaping to meet McGowan's cross and the ball slipped under Brown and into the net to double the hosts' lead.
McGowan was tormenting the visitors and after setting up the first two goals he got on the scoresheet himself when he drove at the United defence before looping a superb chip over the head of the helpless Brown from the edge of the area.
Adam Hunter picked up the second yellow card of the match when he carelessly brought down Thompson.
A miserable first half for Ayr continued when referee Mike Tumility pointed to the spot after Austin McCann brought down Graham Carey.
McLean stepped up to take the resulting penalty and coolly slotted beyond Brown.
The noisy band of visiting fans were given a small reward when Moffat fired beyond Samson on 39 minutes to reduce the deficit to three.
A cynical challenge by Goodwin earned St Mirren their first booking of the match just minutes before the break.
Mark Roberts replaced McGowan with Ross Robertson at half-time but it did little to prevent St Mirren from continuing to dominate proceedings.
McLean flashed an effort wide of target before Goodwin stung the palms of Brown with a drive from distance.
Sinclair shot just wide after 55 minutes as the visitors searched for a way back into the match.
They almost found themselves 5-1 behind a minute later though when Teale robbed McCann before firing over an excellent delivery that Brownlie had to acrobatically clear under pressure from Thompson.
Lennon's first change of the evening came when Van Zanten replaced Marc McAusland.
Teale combined with Thompson before firing a low effort into the bottom-right corner to restore a four-goal lead for the SPL side on 58 minutes.
Two minutes later the former Scotland international almost turned provider for Thompson but an excellent goalline header from Brownlie kept the home sides' tally at five.
Sam Parkin and John Robertson replaced Guy and Goodwin as Lennon looked to rest leg ahead of Saints' trip to face Aberdeen on Saturday.
Thompson and Carey both failed to find the target as the game approached the closing stages.
With four minutes remaining McGowan almost added St Mirren's sixth and his second following some wonderful build-up play between Thompson and Teale.