Two goals in the final four minutes ensured Kilmarnock finished seventh in the Scottish Premier League thanks to a win over Dunfermline Athletic.
Relegated Pars were worthy of their first-half lead courtesy of Paul Willis' close-range finish following a Steven McDougall cut-back.
Kilmarnock dominated after the break and Liam Kelly smashed the ball high into the net for the equaliser.
Jude Winchester then fired the winner with a minute remaining.
And the defeat meant that Dunfermline leave the top flight with only one home win over the course of the whole season.
Bernardo Dominguez Fernandez had been handed his debut in Dunfermline's goal after arriving from Huesca in January.
He was one of seven changes made by Jim Jefferies as the manager prepared for life back in Division One by dispensing with most of the old guard as well as on-loan Rangers midfielder Kyle Hutton.
However, the defensive frailties that have bedevilled the side all season emerged again as Kilmarnock started the better of the two sides.
As Alex Keddie hesitated, Jordan McMillan's hasty attempt to clear struck Gary Harkins and slipped just wide of a Pars post.
Ross Barbour was making his first start for Kilmarnock along with goalkeeper Kyle Letheren, with injury-plagued Ryan O'Leary being handed a rare place in the first XI, in place of Cammy Bell, Chris Johnston and Mo Sissoko.
The young defender looked to be posted missing as McDougall, who was one of the fresh starters for the Pars along with Willis, set up the opening goal.
McDougall headed a Joe Cardle free-kick back across goal for winger Willis to fire his first goal of the season from close range.
The visitors looked more determined after the break and a low drive from William Gros forced Fernandez into a good save with his right boot.
Barbour ought to have done better than head wide from seven yards and Andy Dowie did well to clear from in front of his own goal after Gary Harkins lofted an effort over Fernandez.
Dunfermline appeared to have survived the onslaught, but Kelly pounced to fire into the roof of the net from just inside the box for his first goal of the season.
The Pars thought they equalised seconds later, but Martin Hardie was ruled offside as he knocked the ball home from close range when he perhaps should have allowed fellow substitute Andy Kirk's header cross the line.
Dunfermline paid for that moments later when Lewis Toshney cut the ball back from the bye-line for sub Winchester to fire in the winner.
Sorry, we were unable to load match stats, please try again.
Live Text Commentary
Full Time The referee blows his whistle to end the game.90:00 +2:58
James Dayton produces a right-footed shot from inside the area that clears the crossbar.90:00 +1:50
James Dayton takes a short corner.89:03 Booking
Booking Jude Winchester is cautioned by the ref for leaving the field of play without the referee's permission.88:17
The assist for the goal came from Lewis Toshney.88:17 Goal scored
Goal! - Jude Winchester - Dunf'mline 1 - 2 Kilmarnock Jude Winchester finds the net with a goal from close range low into the middle of the goal. Dunfermline 1-2 Kilmarnock.86:56
The referee blows for offside. Kyle Letheren takes the indirect free kick.85:10
The assist for the goal came from Dean Shiels.85:10 Goal scored
Goal! - Liam Kelly - Dunf'mline 1 - 1 Kilmarnock Liam Kelly fires in a goal from just outside the box to the top left corner of the goal. Dunfermline 1-1 Kilmarnock.83:09
The offside flag is raised against Martin Hardie. Kyle Letheren restarts play with the free kick.81:52
Free kick awarded for a foul by James Fowler on Ryan Thomson. Free kick taken by Andy Dowie.81:06
Inswinging corner taken left-footed by James Dayton from the right by-line, save by Bernardo Fernandez.79:48
Corner taken short by Dean Shiels.79:35
Short corner taken by Liam Kelly.76:39
Martin Hardie challenges Liam Kelly unfairly and gives away a free kick. Direct free kick taken by Liam Kelly.75:41
Paul Willis takes a shot. Kyle Letheren makes a save.75:04
Free kick awarded for a foul by Alex Keddie on Dean Shiels. Dean Shiels takes the free kick.73:22 Substitution
Substitution James Dayton replaces Gary Harkins.72:56
Martin Hardie gives away a free kick for an unfair challenge on Liam Kelly. Liam Kelly restarts play with the free kick.72:04
Martin Hardie fouled by Ryan O'Leary, the ref awards a free kick. Patrick Boyle takes the free kick.
Substitution Martin Hardie comes on in place of Liam Buchanan.67:24 Substitution
Substitution William Gros leaves the field to be replaced by Chris Johnston.65:35
Patrick Boyle fouled by Gary Harkins, the ref awards a free kick. Patrick Boyle restarts play with the free kick.64:34
Michael Nelson gives away a free kick for an unfair challenge on Liam Buchanan. Free kick taken by Andy Dowie.63:27 Substitution
Substitution Steven McDougall goes off and Andy Kirk comes on.63:12 Substitution
Substitution David Graham comes on in place of Joe Cardle.62:38
Inswinging corner taken right-footed by Dean Shiels from the left by-line, Effort from the edge of the box by Liam Kelly goes wide of the left-hand post.62:00
Gary Harkins takes a shot. Comfortable save by Bernardo Fernandez.60:07
William Gros has a headed effort at goal from deep inside the area missing to the right of the target.59:44
Corner taken right-footed by Dean Shiels, clearance made by Mark Kerr.59:25
Lewis Toshney has an effort at goal from 35+ yards. Bernardo Fernandez makes a save.58:25
Header on goal by Gary Harkins from inside the box goes harmlessly over the target.57:26 Substitution
Substitution Jude Winchester is brought on as a substitute for Ross Barbour.57:14
Effort on goal by Dean Shiels from inside the box misses to the right of the target.56:03
Liam Buchanan has a volleyed shot. Kyle Letheren makes a comfortable save.55:38
Gary Harkins takes a shot. Save made by Bernardo Fernandez.52:02
Dean Shiels takes a outswinging corner to the near post.51:02
Corner taken right-footed by Dean Shiels, save by Bernardo Fernandez.50:29
Effort on goal by Gary Harkins from 18 yards. Andy Dowie makes a clearance.49:00
Mark Kerr gives away a free kick for an unfair challenge on Liam Kelly. The ball is swung over by Dean Shiels, Ross Barbour has a headed effort at goal from deep inside the area missing to the left of the target.46:09
William Gros takes a shot. Save made by Bernardo Fernandez.45:01
The referee gets the second half underway.45:00 +0:03 Half time
Half Time The match has reached half-time.44:11
Direct free kick taken by Liam Kelly.44:11 Booking
Booking Booking for Ryan Thomson.43:53
Dean Shiels fouled by Ryan Thomson, the ref awards a free kick.43:02
Free kick awarded for an unfair challenge on James Fowler by Joe Cardle. Lewis Toshney takes the direct free kick.42:08
Dean Shiels has an effort at goal from 20 yards. Save by Bernardo Fernandez.40:36
Liam Kelly takes a shot. Save made by Bernardo Fernandez.39:46
Unfair challenge on William Gros by Alex Keddie results in a free kick. Direct free kick taken by James Fowler.38:42
Joe Cardle takes a outswinging corner from the right by-line to the near post, clearance by Liam Kelly.38:29
Liam Buchanan takes a shot. Lewis Toshney gets a block in.37:43
Shot from long distance by Ross Barbour goes wide of the left-hand upright.34:30
The assistant referee signals for offside against Liam Buchanan. Kyle Letheren restarts play with the free kick.33:57
Unfair challenge on Ryan Thomson by James Fowler results in a free kick. Bernardo Fernandez takes the direct free kick.32:26
Unfair challenge on Gary Harkins by Jordan McMillan results in a free kick. Direct free kick taken by Ben Gordon.31:13
Liam Kelly produces a right-footed shot from just outside the box that goes wide left of the goal.30:50
Outswinging corner taken right-footed by Dean Shiels from the right by-line, clearance by Jordan McMillan.29:09
Corner taken by Dean Shiels played to the near post, clearance by Steven McDougall.28:03
Steven McDougall produces a left-footed shot from the edge of the area and misses to the left of the target.26:54
The assistant referee signals for offside against William Gros. Bernardo Fernandez restarts play with the free kick.26:12
The official flags Ryan Thomson offside. Kyle Letheren takes the free kick.25:16
Ryan Thomson concedes a free kick for a foul on Liam Kelly. Liam Kelly takes the free kick.24:29
Free kick awarded for a foul by Dean Shiels on Mark Kerr. Bernardo Fernandez restarts play with the free kick.21:37
Free kick awarded for a foul by Gary Harkins on Jordan McMillan. Andy Dowie takes the free kick.20:53
Headed effort from deep inside the penalty area by Gary Harkins goes harmlessly over the crossbar.19:04
The assist for the goal came from Liam Buchanan.19:04 Goal scored
Goal! - Paul Willis - Dunf'mline 1 - 0 Kilmarnock Paul Willis finds the net with a goal from inside the six-yard box to the top right corner of the goal. Dunfermline 1-0 Kilmarnock.18:26
Unfair challenge on Steven McDougall by Dean Shiels results in a free kick. Joe Cardle restarts play with the free kick.12:52
Foul by Alex Keddie on Dean Shiels, free kick awarded. Free kick taken by Dean Shiels.8:54
Ryan Thomson challenges William Gros unfairly and gives away a free kick. Direct free kick taken by Ryan O'Leary.8:21
Inswinging corner taken right-footed by Joe Cardle from the left by-line, save made by Kyle Letheren.3:40
Liam Kelly gives away a free kick for an unfair challenge on Ryan Thomson. Andy Dowie takes the direct free kick. Steven McDougall is flagged offside by the assistant referee. Kyle Letheren restarts play with the free kick.3:13
Shot from just outside the penalty box by James Fowler misses to the left of the target.0:00
The match begins.
Live data and text provided by our data suppliers