Hearts progress to the next round of the Scottish Communities League Cup after a nervy victory over Livingston.
Just before the break, Danny Grainger's 25-yard shot deflected into the goal of Livi goalkeeper Andrew McNeil.
In the 61st minute, Mark McNulty robbed Marius Zaliukas, turned and drove into the top-right corner to restore parity.
After 70 minutes, Zaliuskas atoned for his earlier mistake and drove low into the net from a corner and headed a further goal four minutes later.
The visitors started the match well and link up play involving Jordan Morton and Keaghan Jacobs almost allowed Marc McNulty a clear view on goal, but the Hearts defence recovered to clear the danger.
Then Livi midfielder Stefan Scougall played a through ball to McNulty, but the striker dragged his left foot shot just wide of the target.
The home side's first opportunity came when Scott Robinson found himself with a clear view on goal 25 yards out but fired high over the crossbar.
Hearts then began to have a sustained spell of pressure and Callum Paterson was within inches of connecting with a Driver free kick at the back post.
Andy McNeil, the Livingston goalkeeper, kept his side in the game with two great saves within the space of a minute from Scott Robinson.
The match flowed from end to end and Jamie MacDonald in the Hearts goal did well to tip a shot from French midfielder Anthony Andreu round the post.
With the clock ticking towards half time, Hearts took the lead.
Grainger latched onto the ball 25 yards out, his shot took a deflection and wrong footed McNeil, who just failed to claw the ball back from going over the line.
Two minutes into the second half, Hearts had a strong claim for a penalty turned down by referee Steven McLean.
Paterson turned the Livingston defence inside out and tumbled to the ground eight yards out when challenged by Barr, but despite appealing, no penalty was awarded.
Just as the home side looked set to increase their advantage, Livingston took advantage of a terrible mistake in their defence to equalise.
Hearts captain Zaliukas was caught on the ball 25 yards from goal and Marc McNulty drove forward and fired high into the roof of the net.
After a forcing a succession of corners, Hearts' pressure eventually paid off and they regained the lead.
Livi's defence failed to clear a Stevenson corner and Zaliukas fired the ball low into the corner of the net.
The Lithuanian notched his second of the night when once again the visiting defence failed to pick up at a corner.
Hearts manager John McGlynn: "We were well on top and Andy McNeil has made some great saves in the first half.
"We deserved to be at least one in front at the break and as long as we didn't make a mistake I couldn't see them coming back - and we made that mistake.
"He has to then show character and get his head up and he has done that and scored two goals up the other end.
"He's the team captain and you look to him for leadership and he came through for us. We didn't have any doubts that he would."
Livingston manager John Hughes: "We gave them a fright but we just could not hang on to it. We are disappointed with the goals; two set-pieces and a deflection.
"We could do with a physical presence up front, and also at the back to help us defend the type of situations we came up against tonight."
Live Text Commentary
Full Time The match has reached full-time.90:00 +0:21
Corner taken by Anthony Andreu from the right by-line, clearance by Dale Carrick.88:23
Effort from inside the area by Arvydas Novikovas misses to the right of the goal.86:15
Marc McNulty takes a shot. Save made by Jamie MacDonald.84:17
Effort on goal by Daniel Grainger from outside the area goes harmlessly over the bar.84:17 Substitution
Substitution Dylan Easton is brought on as a substitute for Iain Russell.84:17
Anthony Andreu gives away a free kick for an unfair challenge on Arvydas Novikovas.82:28 Substitution
Substitution Andrew Driver leaves the field to be replaced by Dale Carrick.82:28 Substitution
Substitution Ross Gray comes on in place of Jordan Morton.80:48 Substitution
Substitution Callum Paterson leaves the field to be replaced by John Sutton.79:42
Marc McNulty concedes a free kick for a foul on Marius Zaliukas. Marius Zaliukas restarts play with the free kick.76:52
Anthony Andreu takes the free kick.76:52 Booking
Booking Booking for Ryan Stevenson for unsporting behaviour.76:48
Jordan Morton fouled by Ryan Stevenson, the ref awards a free kick.75:17 Substitution
Substitution Callum Fordyce on for Garcia Tena.75:17
Effort from deep inside the area by Callum Paterson misses to the right of the goal.74:18
Garcia Tena challenges Ryan McGowan unfairly and gives away a free kick. Free kick taken by Daniel Grainger.73:08
Assist by Ryan Stevenson.73:08 Goal scored
Goal! - Marius Zaliukas - Hearts 3 - 1 Livingston Marius Zaliukas scores a headed goal from inside the six-yard box. Hearts 3-1 Livingston.72:36
Corner taken by Ryan Stevenson,
Effort from deep inside the area by Arvydas Novikovas misses to the right of the goal.70:23 Booking
Booking Jordan Morton receives a yellow card for dissent.69:14 Goal scored
Goal! - Marius Zaliukas - Hearts 2 - 1 Livingston Marius Zaliukas finds the net with a goal from inside the area to the bottom left corner of the goal. Hearts 2-1 Livingston.68:11
Corner taken left-footed by Daniel Grainger, clearance made by Paul Watson. Corner taken right-footed by Ryan Stevenson, clearance made by Andrew McNeil.65:13
Corner from left by-line taken by Ryan Stevenson.64:19
Ryan Stevenson takes a shot. Andrew McNeil makes a comfortable save.63:26
Callum Paterson concedes a free kick for a foul on Craig Barr. Free kick taken by Andrew McNeil.63:00
Free kick awarded for an unfair challenge on Stefan Scougall by Ryan Stevenson. Jordan Morton takes the free kick.62:02
Ryan Stevenson has an effort at goal from just outside the box which goes wide of the right-hand upright.57:46
Mehdi Taouil takes a shot. Save by Andrew McNeil. Inswinging corner taken from the right by-line by Daniel Grainger. Marius Zaliukas produces a left-footed shot from deep inside the penalty box which goes wide of the left-hand upright.57:12
Free kick awarded for an unfair challenge on Arvydas Novikovas by Ross Docherty. Indirect free kick taken by Daniel Grainger.55:48 Goal scored
Goal! - Marc McNulty - Hearts 1 - 1 Livingston Goal scored by Marc McNulty from the edge of the penalty box to the top left corner of the goal. Hearts 1-1 Livingston.53:40
Free kick awarded for an unfair challenge on Andrew Driver by Garcia Tena. Daniel Grainger takes the direct free kick, Darren Barr takes a shot. Save made by Andrew McNeil. Corner taken by Daniel Grainger. Darren Barr concedes a free kick for a foul on Craig Barr. Andrew McNeil restarts play with the free kick.52:48
Iain Russell takes a shot.51:04
The referee blows for offside. Anthony Andreu restarts play with the free kick.49:53
Unfair challenge on Jordan Morton by Darren Barr results in a free kick. Jordan Morton takes the free kick.48:04
Scott Robinson has a headed effort at goal from deep inside the area missing to the right of the target.45:01
The second half has started.45:00 +1:50 Half time
Half Time The first half comes to an end.44:32 Goal scored
Goal! - Daniel Grainger - Hearts 1 - 0 Livingston Daniel Grainger scores a goal from outside the area to the bottom left corner of the goal. Hearts 1-0 Livingston.43:20
Marc McNulty is flagged offside by the assistant referee. Marius Zaliukas takes the free kick.40:39
Corner taken left-footed by Daniel Grainger from the left by-line, clearance by Paul Watson.37:29
Daniel Grainger takes the inswinging corner, Garcia Tena makes a clearance.37:01
Iain Russell concedes a free kick for a foul on Ryan McGowan. Mehdi Taouil restarts play with the free kick.34:50
Anthony Andreu takes a shot. Save by Jamie MacDonald. Inswinging corner taken from the right by-line by Anthony Andreu.34:26
Free kick awarded for a foul by Callum Paterson on Anthony Andreu. Craig Barr restarts play with the free kick.32:14
Scott Robinson takes a shot. Andrew McNeil makes a save. Corner taken by Ryan Stevenson from the left by-line, clearance made by Garcia Tena.31:46
Darren Barr concedes a free kick for a foul on Craig Barr. Andrew McNeil takes the indirect free kick.31:01
Scott Robinson takes a shot. Save by Andrew McNeil. Corner taken by Daniel Grainger from the left by-line.28:58
Jordan Morton shoots direct from the free kick. Andrew Driver produces a right-footed shot from inside the area that clears the bar.28:58 Booking
Booking Marius Zaliukas is shown a yellow card for unsporting behaviour.28:54
Marius Zaliukas challenges Stefan Scougall unfairly and gives away a free kick.27:56
Ryan Stevenson concedes a free kick for a foul on Anthony Andreu. Andrew McNeil takes the free kick.27:30
Scott Robinson fouled by Anthony Andreu, the ref awards a free kick. Ryan Stevenson restarts play with the free kick.26:52
Arvydas Novikovas takes a shot. Save made by Andrew McNeil.25:14
Daniel Grainger takes a outswinging corner from the left by-line to the near post, Iain Russell manages to make a clearance.25:14 Booking
Booking Garcia Tena is shown a yellow card.25:04
Foul by Garcia Tena on Ryan McGowan, free kick awarded. Daniel Grainger takes the free kick.24:01
Shot by Scott Robinson from a long way out goes over the target.21:54
Jordan Morton gives away a free kick for an unfair challenge on Ryan Stevenson. Daniel Grainger takes the free kick.18:04
Scott Robinson takes the inswinging corner, clearance by Iain Russell.14:53
Darren Barr produces a right-footed shot from long range that goes harmlessly over the bar.13:06
Outswinging corner taken left-footed by Daniel Grainger from the left by-line, clearance by Paul Watson.12:20
Callum Paterson is ruled offside. Andrew McNeil takes the indirect free kick.10:15
Foul by Ross Docherty on Arvydas Novikovas, free kick awarded. Daniel Grainger takes the indirect free kick.8:38
Direct free kick taken by Daniel Grainger.8:38 Booking
Booking Craig Barr receives a caution for unsporting behaviour.8:36
Callum Paterson fouled by Craig Barr, the ref awards a free kick.8:00
Marc McNulty produces a left-footed shot from the edge of the box and misses to the right of the target.5:15
Arvydas Novikovas has a headed effort at goal from close in which goes wide right of the goal.4:48
Marc McNulty gives away a free kick for an unfair challenge on Marius Zaliukas. Marius Zaliukas takes the indirect free kick.3:15
Jordan Morton has a shot on goal from long range that goes wide left.0:00
The match has kicked off.
Live data and text provided by our data suppliers