Nicky Bailey opened the scoring for Middlesbrough with a stunning 30-yard drive early in the second half but it was all Leicester after that, with Jamie Vardy slotting in the equaliser and Dyer's deflected effort winning it at the death.
It was the Foxes' fourth victory in five matches but the first points they have taken on their travels after three defeats.
Bailey and Merouane Zemmama were the only survivors from Boro's midweek Capital One Cup victory at Preston, while the Foxes named an unchanged line-up following their impressive 3-1 Championship win against Hull last Sunday.
The home side had the first chance of the game when Justin Hoyte cut in from the right and fired in an effort which brought a decent stop from Kasper Schmeichel.
At the other end, David Nugent, who scored a hat-trick against the Tigers, saw a shot deflected just over the crossbar by Andre Bikey.
Middlesbrough's on-loan midfielder Josh McEachran fizzed a right-footed drive wide, before Leicester lost Ritchie De Laet to injury, with highly-rated youngster Liam Moore coming on.
Vardy should have done better with a shot from just inside the area which was straight at Boro goalkeeper Jason Steele as the game continued to flow.
Jonathan Woodgate, whose career has been dogged by injuries, was forced off in the 37th minute with what looked to be a recurrence of a niggling hamstring problem.
His absence was noticeable from a Leicester set-piece shortly afterwards as Nugent rose highest to head over the crossbar.
Tony Mowbray's men took the lead early in the second half. There looked to be nothing on when Bailey picked the ball up 30 yards from goal, but the midfielder let fly with a stunning shot into the top corner.
Middlesbrough came agonisingly close to doubling their advantage moments later, hitting City on the break, only for Lukas Jutkiewicz to slam a shot against the crossbar.
They were made to pay as Leicester equalised from their next noteworthy attack.
Nugent's shot deflected into the path of Vardy and he steered the ball past Steele for his fourth goal of the season.
Leicester spurned two gilt-edged chances to take the lead as Dyer cleared the bar from six yards from fellow substitute Andy King's lay-off.
King then found himself with space in the area but his close-range shot was palmed away by Steele.
The visitors were well on top as Anthony Knockaert's corner picked out former Middlesbrough defender Sean St Ledger but his powerful goalbound header was expertly tipped away by the keeper.
Nugent headed wide, before Leicester grabbed the winner their second-half pressure had deserved.
Anthony Knockaert passed the ball wide to Dyer and his shot took a wicked deflection and looped over Steele.
Knockaert should have sealed victory late on when he was sent clear one-on-one with Steele. He took it around him but sub Hines was on hand to hack the ball to safety.