Three first half tries helped Ayr to a 17-3 interval lead, and they hung on despite a late rally from the Knights to book a trip to the Memorial Stadium to play Bristol in the last-eight.
Bristol secured their place in the cup's knockout stages after edging an eight-try thriller against Melrose in the Scottish Borders. That result put Munster out of contention.
Worcester will play Moseley in the only all-English quarter-final tie after seeing off Pool A rivals Cornish Pirates.
Richard Hill's men had the game in the bag by half-time following three tries from Andy Goode, Marcel Garvey and Chris Pennell, who shone in his first home appearance of the season. The boot of Rob Cook accounted for all 12 of the Pirates' points.
Moseley will take on their near neighbours after finishing second to Bedford in Pool C. The Blues came from behind to beat Moseley and complete a clean sweep of pool wins.
Bedford trailed 15-14 early in the second half, but never looked back once Handre Schmidt had crossed for his sixth try of the campaign, the joint best total in the competition.
Pool A runners-up Leinster, whose winger Andrew Conway has also scores six tries, will take on Bedford at Goldington Road next Saturday afternoon (kick-off 3pm). Bedford's squad includes former Leinster back Brendan Burke.
Next weekend's remaining quarter-final will see runaway Pool D winners Pontypridd take on Llanelli in an all-Welsh affair at Sardis Road.
BRITISH & IRISH CUP QUARTER-FINAL FIXTURES:
Saturday, March 5 -
Bedford Blues v LEINSTER, Goldington Road, 3pm
Worcester Warriors v Moseley, Sixways Stadium, 3pm
Pontypridd v Llanelli, Sardis Road, 2.30pm
Sunday, March 6 -
Bristol v Ayr, Memorial Stadium, 3pm