Ayr were first to score, Pat McArthur nipping over in the corner from a close-range line-out. The conversion was missed, an uncomfortable fact of life on the night for the home side, who badly missed the absent Frazer Climo.
West's Connor Davis cut the deficit with a penalty goal two minutes later, before goaling the conversion after Richard Dalgleish's interception try had put the visitors in front.
Davis extended West's lead with a penalty in 16 minutes, but Ayr rallied and forward power enabled skipper Damien Kelly to rumble over wide out for another unconverted try in 20 minutes.
West prop Elliot McLaren was yellow-carded, his absence allowing Ayr to go in front via a penalty try as the beleaguered West pack were forced to repeatedly infringe under their own posts. Mark Stewart's conversion was his solitary kicking success of the night.
The West prop was coming to the end of his ten minute break when Jonno Crossan drove over for another unconverted try, which put Ayr ahead 22-13 at the break. But West pressure paid off as Murray McConnell went over from a close-range ruck, Davis again converting. West's Dave Young was yellow-carded in 57 minutes, Ayr again making their extra man pay with a Johnny McClung try, again unconverted.
West reduced the leeway with another Davis penalty, then McConnell raced 40 metres for a try which, with Davis missing his only kick of the night, put the visitors one point ahead as the game entered its final stages.
The Ayr pack put West through the wringer and eight minutes into added time lock Scott Sutherland charged over from close range and Stewart, with the last kick of the game, stretched Ayr's margin of victory to six points.
Tries: MacArthur, Kelly, Penalty, Crossan, McLung, Sutherland. Cons: Stewart 2.
West of Scotland
Tries: Dalgleish, McConnell 2. Cons: C. Davis 2. Pens: C. Davis 3.
Ayr: G Anderson/D Steele (55); A Wilson, J McClung, M Stewart, C Taylor/Manning (69); J Hunter, AJ MacFarlane; G Reid, P McArthur, S Fenwick/G Sykes (50); D Kelly, S Sutherland; J Crossan, A Dunlop, G Tippett. Bench: S Nimmo, 18 G Siwo.
West of Scotland: B Wright; A Park, R Dalgleish, J Kerr, A McColl-Hagen; C Davis, M McConnell/S Malone (55 - 60); E McLaren, D McKenna, C Johnson; R McAlpine, M Jenkinson; R Kelso, D Young, J Walker. Bench: N Copland, K Connolly, A Symington, S Hunter.
Attendance: 600 Referee: A McPherson