Kilmarnock gave Dunfermline an end-of-season hammering but the Fife club are safe from relegation.
Locke scored his first goal of the season
Kilmarnock skipper Gary Locke met a 26th minute Peter Leven corner and from six yards bulleted a header in for his first goal of the campaign.
The first action of the second half saw Kris Boyd set up midfielder Rhian Dodds for a simple side-foot finish.
Boyd added a third from close range and Gary McDonald produced a neat finish after good work from Steven Naismith.
Dunfermline's superior goal difference meant they started the day safe in the knowledge that only a set of freak results could send them down.
But they gave their fans a nervous time of it with a shoddy defensive display.
The first real action did not arrive until the 13th minute when Killie midfielder Leven fashioned himself some space before thrashing a powerful 25-yard shot just over the crossbar.
Kilmarnock forced a couple of corners in quick succession and from the Leven's second in the 26th minute, they stole into the lead from an unlikely source.
The delivery from the right was met sweetly by Locke, whose header from six yards found its way through Dunfermline's defenders and into the net.
It was the former Hearts' player's first goal of the season, a fine way to celebrate his new two-year deal signed on Friday.
Leven's 40th-minute free-kick from 30 yards was saved easily by Derek Stillie as a poor first half petered out.
The home side doubled their lead just 30 seconds after the restart with the simplest of goals.
Gary Wales fired in a low cross from the right which was laid off by Boyd to the waiting Dodds and the midfielder calmly stroked the ball home from 12 yards.
It was Dodd's first goal for the Ayrshire club and it stunned the visitors although they should have pulled a goal back five minutes later.
Derek Young cut the ball back from the bye line on the right hand side to brother Darren who was unmarked but the Pars midfielder scuffed his shot wide of the target from eight yards.
In the 54th minute, as Dunfermline's defence crumbled, Kilmarnock grabbed a third goal when Boyd diverted Naismith's cross-come-shot.
Ten minutes later, with the Fifers defence all over the place, Naismith set up the unmarked McDonald on he right hand side and the Killie midfielder, playing out of position at right back, shot into the far corner of the net.
Kilmarnock: Combe, Fowler, Hay, Greer, Locke, McDonald, Dodds, Leven (Murray 73), Naismith (Johnston 73), Wales (Nish 81), Boyd. Subs Not Used: Smith, Hamill, Loy, Wild.
Booked: Greer. Goals: Locke 26, Dodds 46, Boyd 54, McDonald 64.
Dunfermline: Stillie, Campbell, Scott Wilson, Skerla, Scott Thomson, Darren Young, Mason, Derek Young (Donnelly 73), Craig Wilson (Labonte 84), Tod (Mehmet 62), Makel. Subs Not Used: Langfield, Hunt, Dunn, Ross.
Booked: Darren Young.
Ref: W Young