3-2 down with 15 minutes to go and pushing hard for an equaliser ? Aberdeen had missed a couple of great opportunities ? but the game was then decided when the referee awarded Accies a controversial penalty, and also send off a Dons player.
Aberdeen U18s travelled to North Lanarkshire on the back of two impressive home wins over St Mirren and Hearts, and an away defeat to Celtic. The young Accies have also started the season strongly. Although they lost to Hearts, they beat Rangers and last time out, away from home, they came from behind to defeat last year's champions Hibernian.
Last season's results between these sides were close and with both teams fielding similar starting XIs, this look like being another tight encounter.
It was a lively start as Ryan One broke down the left and put over a dangerous cross, then at the other end Adam Emslie beat the offside trap, the winger then set up full back Brendan Hamilton, but his shot was always going over.
On seven minutes Aberdeen took the lead and it was a brilliant individual effort from Alfie Stewart. He won the ball himself midway inside the Accies half, he then drove forward before beating Reece Murray down low to his left.
A few minutes later a really well worked break saw Liam Harvey lay the ball off to Emslie, who in turn played a through ball for Harvey to chase, and it took a very good block by Cian Newbury to prevent the Dons doing two up.
On 11 minutes the home side were level, and it was the Hamilton number 11 who equalised. The ball was played quickly out to One who beat his marker before firing a low shot across the keeper into the far corner.
Back came Aberdeen, a clever ball over the top set Harvey free and his shot across the keeper was well saved by Murray at the expense of the first corner of the afternoon. Minutes later Accies won their first corner which was well cleared by Murray.
On 22 minutes the home side took the lead. A cross field ball by One found Patrick Meechan who laid it back to striker Ben Black who produced a fine finish.
Aberdeen then enjoyed a good spell around the half hour mark. Both Bavidge and Emslie managed to get shots on target from inside the area but neither troubled Murray.
But after 34 minutes, and against the run of play at that stage, it was 3-1. Full back Sam Spence ran into space before playing it through to Black and the striker again produced another composed finish. Things almost got worse, but Jared Lyons shot over with the Dons defence all at sea.
Aberdeen should have pulled one back just before the break. Bavidge did well to keep a ball in play on the by-line, Dylan Lobban got on the end of it and forced Murray into a great save before Hamilton hit the rebound into the side netting.
A big blow for the Dons on the stroke of half time as captain Lobban was forced off with an injury. He was replaced by Cammy Wilson.
During the interval Accies took off a couple of players who will be on first team duty tomorrow. It was a scrappy start to the second half as the Dons tried to force their way back into the game - the match was very open but on 54 minutes Barry Robson's side were back in it. Brendan Hamilton produced a brilliant ball which freed Emslie between the lines, and he played in Findlay Marshall. Although his initial shot was saved, the midfielder kept going and forced it back to Harvey who fired home. Game on.
And then on the hour mark the young Dons should have been level. Alfie Bavidge missed a golden opportunity after doing everything right. He beat two players as he drifted across the box, he then cut inside, set himself before placing his shot just over the bar.
Still Aberdeen pushed forward. Bavidge then set up Emslie but his shot was blocked with the keeper out of position. Then a Stewart cross was headed inches wide by Harvey.
Aberdeen looked likely to score an equaliser, but then with just over 15 minutes to go disaster struck.
Accies had broken forward and won a corner after a good block by Kai Watson. From the resulting set piece, the referee awarded a penalty for a push inside the area. On first viewing, it looked an extremely harsh decision. Alfie Stewart was then sent off for something he said. The Aberdeen players were clearly furious about the decision. Black eventually took the spot kick and just managed to squeeze the ball under Oluyemi to complete his hat-trick.
Game over. It was a shame such an enjoyable and competitive game between two good youth sides should end this way.
A few minutes later Cian Newbury headed home a corner and Gabe Forsyth completed the scoring with about five minutes to go.
Even then, Aberdeen continued to create chances, Bavidge had two openings, the second of which in the last-minute saw him run in on goal, beat the keeper but pull his shot inches past the post. That about summed up the 90 minutes.
In the last-minute Adam Emslie limped off to complete a thoroughly miserable afternoon.