Napoli's Dries Mertens scored two minutes from time to give his second-placed side a 3-2 win over Bologna after the struggling visitors twice fought back to equalise in Serie A on Saturday.
Arkadiusz Milik put Napoli ahead on two occasions but Bologna, without a win in 12 league matches, hit back with goals by Federico Santander and Danilo.
Carlo Ancelotti's Napoli side stayed nine points behind leaders Juventus, who have 53 points after a 2-1 win at home to Sampdoria, as the championship reached the halfway mark.
Napoli fans carried pictures and banners of support for defender Kalidou Koulibaly who was subjected to racist insults during the 1-0 defeat at Inter Milan on Wednesday.
The Senegalese was sent off in that game, with Ancelotti blaming the player's loss of temper on the taunts, and was suspended on Saturday.
Ancelotti said: "It's true that we didn't play a great match and, above all, we didn't keep it under control. But we have shown character, otherwise we wouldn't have won it."
"Our season is going according to plan and we have had an excellent first half of the championship although it hasn't looked so good because of Juventus' extraordinary campaign. But we are closer to first place than to fifth."
Milik scored in the 16th minute, prodding the ball home after a series of rebounds, only for Santander to level for Bologna just after the half hour, the Paraguayan getting in front of his marker at a free kick to power home a header.
Napoli regained the lead with a Milik header six minutes after the restart only to concede another goal from a set piece, Danilo this time scoring in the 80th minute as Koulibaly's absence was sorely felt.
Mertens then came to the rescue, cutting inside to score from the edge of the area with a shot which bounced under Lukasz Skorupski, although Bologna nearly levelled again when Napoli's Mario Rui had to clear off the line following a corner.
The defeat kept Bologna in the relegation zone in 18th place with 13 points.