McKay netted the opener from the penalty spot and took advantage of some slack play from the visitors to put Caley Thistle 3-1 up just after the break and take his tally for the season to 18 goals.
A long-range effort from Owain Tudur Jones and a solo strike from Andrew Shinnie also helped move Caley Thistle above Motherwell and take the club beyond the half-century mark in goals at the halfway point of their season.
Dundee midfielder Nicky Riley cancelled out McKay’s opener and there was little in the first half but the home side were in total control after the break.
But Declan Gallagher barged McKay as the pair chased the loose ball along the by-line and referee Kevin Clancy pointed to the spot despite strong protests from the visitors. The Northern Ireland squad player sent Douglas the wrong way to open the scoring.
Irvine blocked Shinnie’s volley as Inverness looked to press home their advantage but the hosts were exposed in the 19th minute when Jim McAlister switched play from left to right as Riley ran forward in yards of space.
The midfielder did well to get the pass under control but still faced a tricky finish and fired the ball in off the far post from 15 yards.
But Inverness went back in front in the 24th minute with a goal out of the blue.
Dundee had bodies behind the ball when Tudur Jones received a pass 25 yards out but the Welsh midfielder was allowed time to shoot and his powerful effort fizzed off the wet surface and evaded the reach of Douglas.
Dundee pushed for an equaliser without carving a clear chance and they shot themselves in the foot within three minutes of the restart when Iain Davidson’s short backpass sent McKay clear.
Douglas came off his line and foiled the striker’s attempt to go round him but the striker swung his leg at the ball as he lay on the ground and steered it into the net.
Douglas pushed Shinnie’s shot wide after Tudur Jones had played him through but the midfielder netted his 10th goal of the season in the 70th minute.
Shinnie collected the ball just inside the box wide on the left and jinked in-between Riley and Kyle Benedictus before curling the ball inside the far corner.