Dyer (13) and Sammy Ameobi (17) both netted early on at The Riverside on Saturday as Tony Mowbray's men bounced back from their midweek FA Cup exit.
Aron Gunnarsson (67) pulled a goal back midway through the second half, but Boro held on to record only their second league win in 2013.
Dyer's goal was his first in the league since 2007 - the 34-year-old midfielder's career having been beset by injury problems. The result ensured Mowbray's Boro kept up the pressure on the teams in the Championship play-offs, while Hull's convincing 5-2 home win over Birmingham saw Cardiff's lead at the top cut to five points after their first away defeat in 10 games.
Ameobi, who joined on loan from Newcastle this week, headed over the bar from Grant Leadbitter's free-kick after just three minutes as the hosts started on the front foot.
And Cardiff failed to heed the warning and fell behind after 13 minutes when former England international Dyer tapped home from Ishmael Miller's ball across the edge of the six-yard box.
It ended a long wait for the ex-Newcastle man, who last scored a league goal against Watford nearly six years ago, and the home fans had further cause for celebration just four minutes later.
Ameobi showed superb control and balance to create space inside the box and he curled a beautiful effort past the helpless David Marshall. In doing so he became Boro's 20th different goalscorer of the Championship season, creating a new club record.
The shell-shocked visitors looked to claw their way back into the match but Peter Whittingham's searching pass was slightly too heavy for Craig Bellamy, who had made a clever run in behind the Boro defence.
Despite enjoying prolonged spells of possession, Cardiff looked more workmanlike than than their lofty league position suggests and they struggled to threaten the hosts' advantage.
There were only glimpses of their promotion credentials and it took a finger-tip save from Jason Steele to deny Whittingham as he tried his luck from the edge of the box before the interval.
Icelander Gunnarsson set up a tense last 23 minutes. Bellamy's delivery from a corner found the former Coventry man six yards out and he headed past Steele.
The lively Bellamy was soon replaced by Craig Noone, with both of Boro's goalscorers substituted at the same time.
Cardiff controlled possession the late stages of the game but Fraizer Campbell, who had managed five goals in his last five matches, could only head wide from Whittingham's cross at the death.