David Noble scored a superb stoppage-time winner as Bristol City beat Crystal Palace 2-1 in the first leg of their Championship play-off semi-final at Selhurst Park.
After a tight first half, the game really opened up after the interval with Louis Carey turning from hero to villain as he opened the scoring for the Robins before giving away a late penalty from which Neil Warnock's side equalised.
But it was Noble who had the final say and Gary Johnson's side now hold the upper-hand going into the second leg at Ashton Gate on Tuesday.
The visitors edged a nervy first period with Palace keeper Julian Speroni forced to make one superb save to keep Dele Adebola's header out.
However, Palace also went close to breaking the deadlock with Scott Sinclair's weak effort being cleared off the line after Adriano Basso had been beaten, while Clinton Morrison also shot straight at the City keeper.
Sinclair almost won a penalty as well but Nick Carle's foul was adjudged to be just outside the area and Danny Butterfield's free-kick was saved by Basso.
After the break Ben Watson fired a shot inches wide for Palace before Carey gave the visitors the lead in the 54th minute after a well-worked free-kick.
City's captain scored his first goal of the season after Noble and Carle combined to create the opening for him to curl a fantastic effort past Speroni.
Palace's woes intensified when Warnock brought substitute James Scowcroft on, only for the striker to almost immediately suffer a recurrence of the hamstring injury that has sidelined him for the last month.
Carey's strike appeared to have won the game for City until the defender brought down Jose Miguel Fonte with only four minutes left and Watson kept his nerve to fire his penalty past Basso.
It seemed certain that the match would end level but, after it was announced that there would be five minutes of stoppage time, former West Ham United trainee Noble hit a perfect 30-yard effort into the net to hand the advantage to the Robins.