Stuart Dallas put Leeds ahead against the runaway leaders in the first half with a shot that went in off the post.
Skipper Liam Cooper was then sent off for a challenge on Gabriel Jesus.
Ferran Torres equalised but Leeds celebrated a famous win after Dallas scored a 91st-minute winner.
The players wore black armbands and there was a period of silence before the game for Prince Philip, the Duke of Edinburgh, who died at the age of 99 on Friday. BBC