Craig Halkett's goals were his second and third since signing from Livingston in the close season

Hearts spared themselves a Scottish League Cup humiliation after coming from behind in the final eight minutes to beat Stenhousemuir at Tynecastle.

Mark McGuigan's 77th-minute goal gave the League Two side the lead, but Craig Halkett scored twice to clinch the win.

It means Craig Levein's will reach the last 16 as long as they avoid defeat at East Fife on Saturday.

Top-flight rivals Ross County clinched their place by beating Forfar Athletic to end the group stage with 12 points.

And Partick Thistle are also through after beating Clyde - a result that leaves Premiership side Hamilton Academical needing to win at Airdrieonians on Saturday and then hope it is enough.

The eight group winners and the four best runners-up all advance to join Scotland's four European representatives in the last 16.

Airdrieonians claimed a bonus point after winning the shootout 12-11

Halkett resuscitates Hearts

With likeliest Group A challengers Dundee United being shocked by East Fife on Tuesday, Hearts had a little leeway given they went into the meeting with Stenhousemuir with two points behind with two games in hand. But this was very nearly an ugly night for Levein and his players.

Hearts dominated their bottom tier visitors, no doubt, but their 30 shots yielded just two late goals after McGuigan threatened a huge upset. The experienced striker, who scored against Aberdeen in the Scottish Cup last term, rammed in from close range and allowed a team relegated last term to dream.

But Halkett, who arrived from Livingston in the summer but has now scored three times in two games, slashed in an equaliser after a corner dropped to him, then headed in a Jake Mulraney deliver to clinch the points and spare his new side's blushes.

"We had to work far too hard," Levein said. "We missed far too many chances but we didn't feel sorry for ourselves and kept plugging away and we should have won by a hell of a lot more."

County cruise into last 16

While some Premiership teams have toiled in these summer matches, Ross County have serenely completed their four fixtures without dropping a point. The top-flight newcomers had scored 10 times in their previous three games - including in Sunday's win at St Johnstone - and added a further two on Wednesday, with Brian Graham netting in each half to swat aside League One visitors Forfar.

Forfar do, improbably, still harbour hopes of finishing as one of the best runners up, but will need to overcome St Johnstone at Station Park on Saturday then cross their fingers.

That might have seemed more likely before the Perth side earned their first points of the competition by thrashing League Two Brechin City 4-0. Scott Tanser and Chris Kane scored in the first half, and Callum Hendry and Matty Kennedy secured the win after the interval.

Weekend off for Thistle

Kenny Miller, second left, scored his second goal for Partick Thistle

Thistle can relax at the weekend, having gathered 10 points from their four fixtures to clinch a place in the knockout stages. A Shea Gordon brace was sandwiched by a Kenny Miller strike as the Championship outfit saw off League One Clyde, who levelled through Tony Wallace and were then given hope by a Stuart Bannigan own goal.

Top-flight Hamilton are their nearest challengers and need to win at Airdrieonians on Saturday to have any chance of progress. However, their League One hosts will have the motivation of being able to leapfrog them with a win after their 2-2 draw with Queen's Park was followed by 12-11 shootout win in which both goalkeepers scored.

What's next?

Elgin City host Hibernian on Friday (19:45 BST) with a win guaranteeing qualification for the Premiership side and a draw also potentially enough. Then the concluding 15 group stages ties will be played across the weekend, with the last-16 draw on Sunday.