Last updated on .From the section Scottish Premiership

St Mirren dropped into the Scottish Premiership bottom two after missing a late penalty in a dramatic defeat to Aberdeen at Pittodrie.

Tony Andreu's spot-kick and rebound were saved by Joe Lewis as the goalkeeper made amends for the foul on Jonathan Obika that gave St Mirren the chance to earn a first away point.

Goals from Sam Cosgrove - his 18th this term - and Niall McGinn either side of an Obika strike secured a fourth win in five for Aberdeen and kept them three points clear of Motherwell in third.

St Mirren fall a place into the relegation play-off spot and are one of three sides on 11 points, with goal difference keeping them above St Johnstone.

Wasteful Andreu sums up St Mirren's woes

St Mirren belied their awful away record with a first-half performance full of verve and menace.

They were helped, though, by disarray in the home defence, with Derek McInnes' players struggling to get to grips with the unfamiliar 3-4-2-1 formation.

The hosts were particularly vulnerable at set-pieces with St Mirren's towering centre-backs Gary MacKenzie and Sean McLoughlin being allowed to maraud forward for a succession of free headers.

Most were sprayed off target and that profligacy - and Andreu's costly failure from the spot - explains why St Mirren are the lowest scorers in the top flight and mired in a relegation battle.

Aberdeen survived an early scare - Andreu's volley well parried by Lewis - before breaking the deadlock through the most reliable of sources.

A Ryan Hedges cross was only partially cleared and Cosgrove was lurking on the edge of the edge to place a finish into the top left-hand corner for his 18th goal from 22 appearances this term.

The lead ought to have been doubled when Lewis Ferguson screwed a diving header wide after Zak Vyner's excellent delivery picked him out unmarked on the six-yard line.

But when St Miren's equaliser arrived, it was merited and owed much to the wing wizardry of Ryan Flynn. He left a trail of red shirts in his wake down the right as he jinked into the box and centred from the byeline for Obika to prod home.

Cosgrove then had a header hacked off the line by Calum Waters before teeing up Hedges to drag a shot wide either side of the restart.

McInnes had reorganised his team at the break and they went full throttle for the three points. The winner duly arrived when Hedges' perseverance down the left led to his cutback being rifled high into the net from 10 yards by McGinn.

The comfort of a third goal eluded the hosts but St Mirren's threat deserted them until the closing stages. Andreu was presented with a clear opening from a Sam Foley cross, only to screw his shot a yard too high.

An even better chance was to come for the Frenchman when Obika chased a pass into the Aberdeen box, got to the ball before Lewis and was clipped by the goalkeeper's arm.

The visitors were screaming for Lewis to be sent off but referee Steven McLean opted only for yellow. And the 32-year-old made the most of his reprieve, with Andreu's botched spot-kick summing up St Mirren's away-day woes.

Man of the match - Niall McGinn

BBC Scotland's Tyrone Smith at Pittodrie

It was tempting to go for a St Mirren player as they put so much into this game, but Aberdeen's McGinn gets the nod. He might not have the influence he used to, but he still has the ability to be a match-winner.

And that is what he did here. The winger grew into the game in the second half, his composure, guile and eye for goal helping get his side out of a difficult situation.

'Lewis should have been off' - reaction

St Mirren manager Jim Goodwin: "I'm not going to stand here and ask for people to be sent off, but my understanding of the law is goalkeepers can make a genuine attempt to play the ball.

"There is no attempt to play the ball - Obika knocks the ball by him, Lewis sticks out his left arm and pulls him to the ground. He shouldn't be on the park to face the penalty and make the save.

"I think we merited a point. For large spells we played really well. It has happened far too often this season - we have to do something about it or we'll never get out of this position."

Aberdeen manager Derek McInnes: "Joe has actually tried to take his arm away. Greg Leigh is coming round on the cover as well, so I think a yellow card is the right decision.

"Fortunately we have a keeper who is worth 12-15 points to me and he showed why today. His double save was excellent and thankfully we got a deserved three points on balance of play and chances."