St Johnstone began their defence of the William Hill Scottish Cup with a 2-1 win over Ross County at McDiarmid Park on Saturday.
Michael O'Halloran and James McFadden scored early on for Tommy Wright's team but Jake Jervis pulled one back in the second half.
David Clarkson grabbed a last-gasp winner as Dundee beat Aberdeen 2-1 at Dens Park. Thomas Konrad netted at both ends before Clarkson struck for the eighth match in a row.
Dundee United came from behind to see off Motherwell 2-1 at Fir Park with goals from defenders John Souttar and Keith Watson after Henrik Ojamaa had given Well an interval advantage.
Ryan Stevenson grabbed a double as Partick Thistle defeated Hamilton Accies 2-0 at Firhill, with Dougie Imrie sent off for the visitors late on.
The fifth all-Premiership tie ended 1-1 in Paisley. Marc McAusland had St Mirren in front but Josh Meekings levelled for Inverness CT in the second half.
Hibernian hit back to beat Alloa 2-1 at the Indodrill Stadium, Liam Craig and David Gray scoring after Daryll Meggatt's early opener for the Wasps. Hibs held on despite a late red card for Dominique Malonga.
Queen of the South racked up a 4-1 victory over Highland League leaders Brora Rangers with goals from Derek Lyle, Gavin Reilly, Iain Russell and Lewis Kidd. Andrew Greig claimed a consolation for Brora.
Craig Sibbald got the only goal with 17 minutes left as Falkirk edged out Cowdenbeath 1-0 at the Falkirk Stadium while Raith Rovers were 2-0 winners at Stirling Albion thanks to goals from Barrie McKay and Grant Anderson.
League 1 leaders Morton suffered a shock 2-1 defeat against Lowland League Spartans at Ainslie Park. Jim Duffy's side scored first through Andy Barrowman but Willie Bremner equalised and Jack Beesley pounced in the last minute after Stefan McCluskey had been sent off.
Stranraer scored twice in the last 10 minutes to earn a 2-2 draw with Dunfermline at Stair Park. Andy Geggan and Gregor Buchanan struck for the Pars but Willie Gibson and Craig Malcolm replied to force a replay.
Brechin City were held to a 1-1 draw at Annan - Colin Hamilton gave the visitors the lead but Matty Flynn equalised on the hour mark.
League 2 leaders Arbroath dismissed Junior side Bo'ness United 5-0 at Newtown Park. Simon Murray hit a hat-trick and Paul McManus weighed in with a double for Allan Moore's men.
Michael Dunlop equalised with six minutes to go as League 2 rivals Berwick Rangers and Albion Rovers drew 1-1 at Shielfield after Darren Lavery scored early on for the hosts.
There are two ties on Sunday, both of them live on Sky Sports. Rangers are at home to Kilmarnock, kick-off 12.45pm and Hearts take on Celtic at Tynecastle with a 3.15pm start.
The draw for the fifth round takes place at Hampden at 2.00pm on Monday.