Rotherham suffered a hammer blow to their bid to avoid Championship relegation as Swansea twice came from behind to claim a dramatic 4-3 win at the Liberty Stadium.
Paul Warne's Millers led 2-1 at half-time thanks to goals from Michael Ihiekwe and Matt Crooks, either side of Oli McBurnie's 20th effort of the season.
A thrilling contest saw Swansea turn the tables through Barrie McKay, a controversial George Byers effort and McBurnie's second before Rotherham's Will Vaulks struck again for the visitors.
Swansea dominated the early possession, but it was Rotherham who went ahead.
After in a long throw the ball rebounded to visiting skipper and Wales international Vaulks, who swung his cross back into the box.
Centre-half Ihiekwe was still up following the throw-in and, although his headed contact was minimal, it was still enough to beat Kristoffer Nordfeldt in the Swansea goal.
Jon Taylor then worked Nordfeldt, while at the other end Wayne Routledge had a stunning finish from a Matt Grimes pass ruled out by the offside flag.
For all their possession Swansea looked short of energy and like they had little to play for. The opposite was true of Rotherham, who came close to conceding when Connor Roberts went close.
Mike van der Hoorn did likewise from a corner, but Swansea levelled from another set-piece when Grimes' pin-point delivery from the right was headed home by McBurnie.
But parity was short-lived as, almost straight from the kick-off, Vaulks delivered another long throw, Van der Hoorn could not clear and the ball fell to Crooks, who delivered a smart half-volleyed finish on the turn which found the bottom corner.
Only a superb save from Nordfeldt stopped Michael Smith from making it 3-1.
Swansea swapped Jay Fulton for Byers in midfield at half-time and the home side made it 2-2 almost straight away. Dan James - who had had a quiet game to that point - tricked his way down the left wing and his cross was converted by McKay for a rare headed goal.
Ihiekwe came close to a second when he headed a corner straight at Nordfeldt.
The Rotherham defender was then at the centre of controversy. As he lay on the floor injured, Swansea broke clear through McKay, who squared the ball to James. A goal looked certain, but Millers goalkeeper Marek Rodak saved twice from James in quick succession.
Swansea moved ahead for the first time when Byers shot from distance and the ball went in off Kyle Naughton. Rotherham's players were furious as they thought Naughton had handled and Vaulks led their protestations, but the goal stood.
Crooks was denied again by an acrobatic Nordfeldt save before McBurnie made it 4-2 in the 79th minute with a low curling finish.
Vaulks then volleyed home to ensure a nervous finish for the home fans and Nordfeldt saved well again from Smith.
Rotherham pushed hard for an equaliser and Rodak went forward in eight minutes of added time, but Swansea held on.