Celtic will begin their Viaplay Cup defence at Kilmarnock in one of two all-Premiership ties in the last 16.
St Mirren face Motherwell in Paisley, while last season’s runners-up Rangers entertain Greenock Morton.
Aberdeen visit third-tier Stirling Albion, Hearts host Partick Thistle, and Hibernian welcome Raith Rovers.
Ross County are away to Airdrieonians and Livingston are at home to Ayr United. The ties will be played on the weekend of August 19-20.
Raith claimed the final place in the last 16, qualifying as third-best runners-up from the group stage on goals scored after Dundee – needing to win by two or more – could only beat Inverness Caledonian Thistle 1-0 on Sunday.
European representatives Celtic, Rangers, Aberdeen, Hearts and Hibs all enter at the last 16 and were seeded in the draw along with the three group winners with the best records – Airdrie, Ayr and Motherwell.
Having stunned top-flight St Johnstone with a 4-0 away win to advance, Stirling Albion are rewarded with a trip to last season’s third-place Premiership side Aberdeen.
Fellow surprise package Airdrie – the only team to emerge from the groups with a 100% record – will aim to upset 2016 winners County at home.
Celtic, who beat Rangers 2-1 in last season’s final before going on to complete the domestic treble, are seeking a third consecutive triumph and have won the trophy in seven of the past nine seasons.
Viaplay Cup last-16 draw
Hibs v Raith Rovers
Stirling Albion v Aberdeen
Airdrieonians v Ross County
St Mirren v Motherwell
Rangers v Greenock Morton
Kilmarnock v Celtic
Hearts v Partick Thistle
Livingston v Ayr United
- Our coverage of your Premier League club is bigger and better than ever before – follow your team and sign up for notifications in the BBC Sport app to make sure you never miss a moment