Cove Rangers will take on Rangers for the first time in their history in the Scottish Cup third round.
Former Celtic midfielder Paul Hartley's League Two champions will travel to Ibrox in the final weekend of January.
Holders Celtic have been handed a home tie against Arbroath or Falkirk.
Hamilton will host St Mirren in the only all-Premiership tie.
Dundee have been handed a home Tayside derby against St Johnstone after scraping past non-league Bonnyrigg Rose on Saturday night.
James McPake's side needed an equaliser from Jonathan Afolabi deep into stoppage-time to force extra-time at Dens Park, and they again came from behind to win 3-2.
With a number of games postponed over the weekend, the only other decided tie will see 2016 winners Hibernian travel to Dumfries to take on Queen of the South.
Ross County have been handed a home tie against either Highland rivals Inverness or Highland League side Buckie Thistle.
Dundee United will host Partick Thistle or Cowdenbeath while Aberdeen will either make the relatively short trip to Huntly or face a longer journey to Dumbarton.
Motherwell will either travel north to take on Fortmartine or south to face Annan while Livingston will host either Stirling or former manager John McGlynn's Raith Rovers side.
Kilmarnock face a trip to either Peterhead or Stenhousemuir while Hearts, runners-up in the past two seasons, will face Stranraer at home if they can get past either Camelon or Brora Rangers, who have still to play their first-round game.
Scottish Cup third-round draw
Camelon or Brora Rangers or Heart of Midlothian vs Stranraer
Celtic vs Arbroath or Falkirk
Dumbarton or Huntly vs Aberdeen
Dundee United vs Partick Thistle or Cowdenbeath
Dundee vs St Johnstone
East Fife vs Greenock Morton or Dunfermline Athletic
Elgin City or Ayr United vs Keith or Clyde
Forfar Athletic vs Airdrieonians or Edinburgh City
Formartine United or Annan Athletic vs Motherwell
Fraserburgh vs Nairn County or Montrose
Hamilton Academical vs St Mirren
Livingston vs Stirling Albion or Raith Rovers
Peterhead or Stenhousemuir vs Kilmarnock
Queen of the South vs Hibernian
Rangers vs Cove Rangers
Ross County vs Buckie Thistle or Inverness Caledonian Thistle