Trailing 26-0 with just over four minutes of the 14-minute tie remaining, the Scots looked dead and buried in the straight knock-out tournament against the Kenyans in the early hours of Saturday morning.
However, Harvey Elms grabbed a try to give a glimmer of hope and John Dalziel’s men never gave up.
A second try came from skipper Scott Riddell –- this one converted by Robbie Fergusson – and a penalty try worth seven points then followed.
A Kenyan was yellow carded for stopping Elms scoring when that penalty try was given, but even then they were still down 26-19 and time was running out.
Somehow Farndale managed to squeeze in at the corner for the Scots’ fourth try and Fergusson kept his nerve to drop kick the conversion from the corner to make it 26-26.
By this point the Kenyans had lost the plot and had been reduced to five men with a second yellow card before, in injury time, Farndale went in at the opposite corner for a dramatic winner.
Head coach Dalziel said: “I’m hugely relieved. We were staring down the barrel for a while there, but I feel in times like that you find out what you’ve got as a group.
“We’ve got a young team who have really came together on an off the field and we’ve said all week that there is something brewing with this team.
“They’ve learned a lot of harsh lessons and have been on the wrong side of things all series and it was their moment.
“I thought the impact off the bench was outstanding. We knew that Jack Cuthbert and Max McFarland would have a say in the game coming on at half-time. In the second half, Jack and Jamie worked at the restart and the kicking of Robbie earned us some key possession.
“But we know how close we came to a disappointing start and to being knocked out of the main competition.”
Fergusson added: “I am a bit lost for words. Once Kenya got the first yellow card we knew we had a chance, but we all had to pull together to get this over the line.”
Earlier in the match the Kenyans were only in the Scots’ half twice in the first half yet came away with 14 points.
A try right from the second half kick-off then put them 19-0 up and when try No 4 came and was converted they had one foot in the last eight – before the amazing turnaround.
The Scots were set to regroup and face South Africa in the last eight late last night UK time. The South Africans thumped Ireland 45-7 in their last-16 tie.