Hearts will play Camelon or Brora Rangers in the second round of the Scottish Cup.
Robbie Neilson's side were beaten in this month's rearranged final from last season.
East of Scotland League side Camelon and Highland League Brora's first-round tie was abandoned at 0-0 on Saturday.
Linlithgow Rose's prize for beating senior side Brechin City is an away tie with Forfar Athletic and the ties will be played on the weekend of 9 January.
Scottish Premiership sides, including holders Celtic, enter at the third-round stage.
Highland League sides Buckie Thistle, Formartine United, Nairn County and Fraserburgh have all been drawn at home with Annan Athletic facing a long trip to play Formartine.
Second-tier Inverness Caledonian Thistle, who play in the Highlands, will visit Buckie.
Paul Hartley faces his former club when Cove Rangers travel to take on Alloa Athletic.
Greenock Morton host Dunfermline Athletic in the only all-Championship tie.
Tranent, playing in the competition for the first time, will visit East Fife.
Draw in full
Kelty Hearts v Stranraer
Keith v Clyde
Arbroath v Falkirk
Dumbarton v Huntly or Cumbernauld Colts
Stirling Albion v Raith Rovers
Buckie Thistle v Inverness Caledonian Thistle
Forfar Athletic v Linlithgow Rose
Camelon or Brora Rangers v Heart of Midlothian
Dundee v Bonnyrigg Rose Athletic or Bo'ness United
Formartine United v Annan Athletic
Nairn County v Montrose
Elgin City v Ayr United
East Fife v Tranent
Alloa Athletic v Cove Rangers
Airdrieonians v Edinburgh City
Peterhead v Stenhousemuir
Fraserburgh v Banks O'Dee
Greenock Morton v Dunfermline Athletic
Partick Thistle v Cowdenbeath
Queen's Park v Queen of the South
Ties to be played weekend of 9 January