Holders Celtic will take on Partick Thistle in the last 16 of the Scottish Cup.
Brendan Rodgers’ men thrashed Championship side Brechin 5-0 on Saturday and will now host the Jags in round five following Sunday’s draw.
Highland League side Brora Rangers were rewarded for their victory over East Fife with a trip to take on Premiership side Kilmarnock.
Hearts’ fourth-round win over Edinburgh rivals Hibernian set up a match against Albion Rovers or St Johnstone, Ayr will be at home to Fraserburgh or Rangers and last year’s runners-up Aberdeen will host Dundee United.
The winner of the replay between Dundee and Inverness will host Motherwell while Formartine United or Cove Rangers will face Livingston or Falkirk. The final tie pits Morton against Peterhead or Dumbarton.
The ties will be played on the weekend of February 10 and 11.
Scottish Cup fifth round draw:
Formartine United/Cove Rangers v Livingston/Falkirk
Greenock Morton v Peterhead/Dumbarton
Hearts v Albion Rovers/St Johnstone
Kilmarnock v Brora Rangers
Ayr United v Fraserburgh/Rangers
Aberdeen v Dundee United
Dundee/Inverness CT v Motherwell
Celtic v Partick Thistle