City's determined second-half performance was not enough to earn a point at Cardiff.
The home side took control of the match in the first period, but the Imps showed real determination and resilience in the second half.
The Imps threatened inside the opening minutes, with just three minutes on the clock when Chieo Ogbene got past two home defenders before being stopped. Sonny Bradley quickly won the ball back and Ben House did well to meet Adam Reach's left-wing cross with a glancing header - although he could not direct the ball close enough to goal.
The home side played their part in an entertaining opening, with Yousef Salech heading over Chris Willock's cross shortly afterwards.
Jack Moylan fired Cardiff ahead after 11 minutes with a powerful low shot into the bottom right corner after ani incisive pass from home captain Rubin Colwill.
Wickens had to be alert to pull off a great diving save from Rubin Colwill's shot from rage.
And at the other end a great move almost ended with Ivan Varfolomeev getting on the end of Adam Reach's ball through - home keeper Nathan Trott was out quickly to get to the ball ahead of the Ukrainian midfielder.
City built up some good pressure with a run of successive corners, but could not convert any into clear chances.
Cardiff's second goal came after 40 minutes. A shot from a free-kick was successfully blocked, but the rebound was then rolled out to Moylan whose first-time shot again found a bottom corner.
The home side added a third through Robin Colwill before the break after winning the ball back high up the pitch.
Freddie Draper was sent on at half-time, and the Imps started the second period positively.
Deji Elerewe flicked an effort over early after the restart, and Ogbene saw an effort come crashing back off the bar.
Hackett pulled a goal back on the hour mark as he scored straight from a corner - Elerewe challenged for the ball, but it eclipsed him and a jumping home defender to find its way into the net.
Moments later a Dom Jefferies pullback was cleared by Calum Scanlon.
Hackett grabbed City's second goal of the game after 63 minutes, heading in Varfolomeev's corner.
The Imps really believed they could get something out of this game now, and it took a great save from Trott to keep out House's diving header from a Hackett cross.
The second period was dominated by the visitors, with Andrei Coubis having a shot deflected behind.
Draper was inches away from getting on the end of Hackett's chipped ball over after 78 minutes.
City kept up the late pressure, with House going close again with a header.
There was late drama as Krystian Bielik cleared a Draper header off the line following a scramble in the area.
The last chance, in time added on, fell to Tom Bayliss who flicked a header just over.
Cardiff City: Trott, Fish, Bagan, Bielik, Moylan, Salech, R.Colwill, Willock, Robertson, J.Colwill, Ashford. Subs: Tyrer, Tanner, Turnbull, Scanlon, Tankiewicz, Kpakio, Holt, Perrett, Davies
Imps: Wickens, Reach, Coubis (Melia, 89), Hackett (Street, 82), Ladefoged (Draper, 46), Bradley, House, Varfolomeev (Bayliss, 82), Elerewe, Konak, Ogbene (Jefferies, 60).Subs: Gauci, Towler, Elder, Oyegoke.
Referee: John Busby