Last updated on .From the section Football

A dramatic finish for Hearts clinched a last-minute spot in the Scottish League Cup quarter-finals.

Killie's Josh Magennis headed home the only first-half goal as the hosts took the initiative.

Alim Ozturk found the net for the visitors before a second from Magennis put the hosts back in front.

But a late equaliser from substitute Juanma Delgado left it looking like extra-time before Sam Nicholson bagged the winner for Hearts.

Having won their first seven games in all competitions, Hearts' season had faltered with three straight league defeats. Killie, on the other hand, had found their form with back-to-back wins going into the cup tie.

And it was the home side who took the lead following some excellent build-up play.

Kallum Higginbotham found teenager Greg Kiltie, who turned Igor Rossi inside out before crossing for Magennis to head home.

Magennis (far right) twice put Kilmarnock ahead

However, Killie were forced into a change when Stuart Findlay had to be carried off the pitch after receiving a knock to his face, Steven Smith his replacement.

Nicholson had a chance to find the target when set up by Morgaro Gomis but the winger's effort was saved by Mark Ridgers, who joined Kilmarnock on an emergency loan on Tuesday amidst a shortage of goalkeeping options.

Hearts continued to make in-roads towards goal in the second half and and Danny Swanson's replacement Juanma did brilliantly to flick a Nicholson cross, but Ridgers saved again.

The leveller came when Ozturk fired a shot through a ruck of players from the edge on the box after Kilmarnock had failed to clear a corner.

Parity did no last long, though, as Higginbotham was allowed to stride forward unchallenged before setting up Magennis, who turned and sent a low drive into the bottom corner.

Still, Hearts would not be beaten and extra-time looked to be on the cards after Juanma's glancing header from Jamie Walker's cross found the net.

But there was another twist in the tale as Juanma mis-hit a shot 10 yards out and the ball fell straight into the path of Nicholson to strike home.

A traumatic end for Kilmarnock who must have thought by then they had done enough to win but it is Hearts who head through to Monday's last-eight draw.

Hearts head coach Robbie Neilson: "I thought we actually played well in quite a lot of the game.

"We lost a really bad goal at the start but we'd started well, first 10-15 minutes really well, dominating the game. But losing a goal from a cross, which was disappointing and it gave Killie a lift, it was difficult to get our passing game going again.

"Second half, I thought we passed well again, got back in it, got the goal to make it 1-1 and looked like we'd go on to win it and then lost another sloppy goal.

"It was then really gung-ho stuff, trying to get a wee bit of discipline in the game and keep going and when we got the equaliser I thought, 'we'll take that', and then we got the winner.

"Great to get through but shouldn't be losing two goals and it's something we really need to nail down."

Kilmarnock manager Gary Locke: "Cruel one for us tonight, I thought our performance was really good.

"We looked a real threat, played some terrific stuff but just that little bit of luck you need to get through in the cup eluded us tonight.

"Huge blow for us, everyone is really, really disappointed in there because we put so much into the game but football can be cruel as I certainly don't think we deserved that.

"The fans here are sensible supporters, they will have seen how well the boys played there and the effort they put in and some of the stuff we played was excellent, you just need that wee bit of luck as well and we didn't get that tonight."