The 34-year-old midfielder, whose career has been beset by injury problems, put the hosts ahead before debutant Sammy Ameobi doubled their advantage.
Aron Gunnarsson's seventh goal of the campaign reduced the deficit after the break but there was no way back for Cardiff.
The result ensured Tony Mowbray's Boro kept up the pressure on the teams in the play-offs, while Hull's convincing 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 in May 2007, 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 npower Championship season, creating a new club record.
The shellshocked 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.
Mowbray's mean threatened first in the second half, with Miller's powerful strike smartly saved by Marshall.
Gunnarsson's effort at the other end was wayward and prompted Malky Mackay to make a change, introducing Heidar Helguson in place of Tommy Smith.
But it was his fellow Icelander Gunnarsson whose effort 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.
- Sports & Recreation
- Sammy Ameobi