Pat MacArthur’s side will now approach the second half of this Super6 campaign with real belief that they can chase down current pacesetters Watsonians and Southern Knights in their five remaining matches.
No8 MacPherson powered in for two early tries, then burrowed over for his third just before the final-whistle, while full-back Elias Cavan, winger Robbie Nairn and replacement-scrum-half Jordan Lenac also dotted down for the hosts.
Tom Jordan and Matt Minogue each kicked two conversions, while Jordan also slotted a first half penalty.
MacArthur said afterwards that he was delighted but not surprised by his team’s performance after a tough start to the season which had seen the Bulls manage just one win from their first four outings.
"There has been a lot of tough times over the last few weeks because we know what potential we have in this squad and we believe in what we're doing, but it's just not been clicking for the boys," he said.
"But we've kept the faith, and that was a first step in the right direction for us,” he added. "If you look at the spine of our team, there is a lot of young boys in there, and they are learning all the time.”
Heriots’ only points came from a James Couper try, which was converted by Bruce Houston, early in the second half.
The Edinburgh side were a distant second in almost every aspect of the game, which is bewildering given how good they had been when hammering Watsonians the previous week, and head coach Andy Kelly conceded that some tough questions need to be asked about what went wrong.
"Fair play to Ayr, they started really well and won the physical contest around the pitch, really," he said. "They put us under a lot of pressure at breakdown, they nullified our maul, and we just couldn't get going.
"Everyone has got to be honest with themselves and have a look at their performance then take it from there. We need to do that as coaches and as players. We'll come back stronger from this, but we just need to have a bit of honesty within the group."