Ipswich Town 3 Leeds United 2: Marcelo Bielsa's play-off preparation ends on a sour note
Leeds fell behind in the 30th minute when Flynn Downes converted after the Whites failed to clear Alan Judge's free-kick but Mateusz Klich equalised from Luke Ayling's cut-back on the stroke of half time.
Ipswich netted their second goal just two minutes after the restart with Leeds carved apart before Andre Dozzell slammed the ball past Kiko Casilla.
United again drew level with 14 minutes left when Stuart Dallas netted on the rebound after Roofe's header had hit the crossbar and Roofe was then presented with the chance to net the winning goal when brought down in the area by for a penalty by Ipswich captain Luke Chambers who was sent off.
Yet Roofe lost his footing and sent the ball spiralling over the crossbar and a miserable day for Leeds ended with Ipswich bagging a 90th minute-winner when Casillafailed to gather a ball on the edge of the box leaving Collin Quaner the simple task of tapping the ball into an empty net.
Leeds still finish the season third despite the defeat with Derby County beating West Brom at Pride Park to set up a two-legged play-offs semi final against the Whites with Aston Villa and West Brom meeting in the other semi final.
Leeds had early chances through the back from injury Kemar Roofe who pulled a shot wide and Klich who volleyed well wide of the left hand post.
But a poor pass from Stuart Dallas then put United under pressure leading to Downes unleashing an attempt from inside the area that was deflected wide off PontusJansson for the game's best chance so far.
Leeds hit back with Pablo Hernandez playing in Adam Forshaw whose effort was parried away by Bartosz Bialkowski to Hernandez who sent the rebound over the bar.
But it was hearts in mouths time in the 29th minute when Whites 'keeper Kiko Casilla came racing off his line trying to clear a long ball ahead of the onrushing Collin Quaner.
The Ipswich striker got there first with Casilla catching Quaner and only booked and not sent off with the incident out wide, 20 yards out and with covering defenders.
Nevertheless, Ipswich were presented with a free-kick which Judge delivered into the box and Ipswich capitalised on hesitant defending with the impressive Downesstabbing the ball home from close range.
Leeds provided a limited response with Roofe seeing a close range effort from a Dallas cross blocked by Toto Nsiala.
Liam Cooper then saw an effort deflected wide before Klich blazed a powerful volley from the edge of the box over the bar.
But Leeds drew level in the final minute of the half when a long ball from Adam Forshaw was kept in by Ayling who cut the ball back to Klich whose fierce first-time effort flew past Bialkowski.
But Ipswich regained the lead just two minutes into the second half with Leeds carved apart through the middle as the hosts worked the ball to Dozzell who had plenty of space and time to fire past Casilla from just inside the box.
There was little immediate response from Leeds with Roofe putting a shot well over but Leeds began to turn the screw around the hour mark.
Hernandez saw one effort saved by Bialkowski and another blocked before a Roofe header was palmed over the bar by Bartosz Bialkowski.
Cooper then narrowly sent the ball wide from a corner before Bialkowski produced a fine double save to keep out first substitute Jack Clarke and then Hernandez.
But Leeds finally drew level for the second time in the 76th minute when a Roofe header came back off the crossbar but into the path of Dallas who bundled home the rebound.
Leeds then looked all set to go on and win the game when the Whites were awarded an 82nd-minute penalty with Luke Chambers sent off for taking down Roofe as the last man in the box.
But Roofe completely lost his footing taking the spot kick which was sent well over the crossbar.
And the game was to have one final twist with Casilla failing to gather a ball on the edge of the box leaving Collin Quaner the simple task of tapping the ball into an empty net with United's Jack Harrison then denied an equaliser in the fifth minute of added time by a fine sliding tackle from Nsiala to deflect his effort away.
Leeds United: Casilla, Dallas, Cooper, Jansson, Ayling, Phillips, Klich, Forshaw (Clarke 61), Harrison, Hernandez, Roofe. Subs not used: Peacock-Farrell, Berardi, Edmondson, Shackleton,Gotts, Bogusz.
Ipswich Town: Bialkowski, Bree, Chambers, Nsiala, Kenlock, Skuse, Chalobah, Downes (Jackson 62), Dozzell, Judge, Quaner. Subs not used: Gerken,Harrison, Elder, Emmanuel, El Mizouni, K Brown.
Referee: Gavin Ward.
Attendance: 20,895 (3,963 Leeds).