Cotterill's 10th goal of the season was one of his best, breaking the deadlock six minutes from time with a mazy run and curling finish to send Rovers second in the table.
It was rough luck on Colchester, who crashed to their eighth successive defeat despite looking the better side for large parts of the game.
Doncaster were not at their best and struggled to string their passes together as the visitors controlled the game in midfield.
Dominic Samuel and Drey Wright went close for Colchester before new loan signing Emile Sinclair threatened with a shot on the turn at the other end.
Rovers were second best in the first half but they began to step up the pace after the interval with the hard working Iain Hume having a close-range shot saved and another effort blocked in quick succession.
The hosts were rewarded for their persistence when Cotterill produced a flash of inspiration with a brilliantly-taken goal in the 84th minute, dribbling past a defender before curling a shot into the roof of the net.