The Foxes were good value for this win, but they only managed to put one past impressive home keeper Dean Gerken.
Nigel Pearson's side dominated for all but the last ten minutes, but time and time again they were denied by the acrobatics of Gerken.
Dyer netted what proved the winner early in the second half. The goal came from a Colchester corner which broke down and suddenly Dyer was away and in the clear.
The former MK Dons striker exploited acres of space down the left flank before beating Gerken with an angled drive from the left edge of the penalty area.
It was Dyer's fourth goal of the season and it had to be good to beat Gerken.
The Us keeper performed acrobatics to divert a deflected shot from Steven Howard over the bar and he also denied fellow striker Matt Fryatt in a one-on-one situation to keep his side in with a shout.
And Gerken's fine saves almost gave his side a point as winger Mark Yeates struck a post with just nine minutes remaining.
It was an agonising moment for the home side and Irishman Yeates as his wonderful 30-yard free-kick beat keeper Dave Martin but struck the inside of the far post and rolled to safety.
Colchester also had a couple of late chances as John White was just inches away with a fierce drive and midfielder Johnnie Jackson lifted a shot over the bar in stoppage time.
This result is a blow to Colchester caretaker manager Kit Symons' chances of landing the job full-time, although he must have been delighted with the attitude and commitment shown by his side.
As for Leicester, they have dislodged Oldham at the top of League One and look strong favourites to win automatic promotion back to the Championship at the first time of asking.