Second-half goals from Emmanuel Ledesma and Albert Adomah ended Millwall's seven-match unbeaten home run to give Aitor Karanka his second win as Middlesbrough boss.
Ledesma brilliantly bent the ball into the corner from 20 yards after cutting inside from the right.
Then Adomah rounded goalkeeper David Forde before rolling the ball into an empty net in the dying minutes.
Millwall's Steve Morison had a header well saved by Shay Given.
Both goals were greeted by the Middlesbrough players holding up a shirt with the name of team mate Stuart Parnaby on after he and his wife
lost what would have been the couple's first baby just four weeks short of full-term.
Karanka was appointed Middlesbrough manager in November but the ex-Real Madrid assistant boss has struggled to make an impact in the north east.
Since his appointment, Middlesbrough had won once, drawn once and lost three but Saturday's win lifts them two points above fellow strugglers Millwall.
Millwall have won just two of their last 12 matches and are four points clear of the relegation zone.
In a drab first half, Liam Feeney provided Millwall with their best moment when he burst down the right, but his tame cross could only find Boro's Jozsef Varga.
On his first league start of the season, Ledesma broke the deadlock four minutes after the restart and Richard Smallwood should have made it two but he fired the goal-scorer's cutback over from 10 yards.
Adomah did seal the points though when he rounded Forde to cap a deserved victory.
Millwall manager Steve Lomas:
"There wasn't much quality on display from either side and it's disappointing to concede again from our own attack.
"We huffed and puffed but the creativity we've shown at home in recent weeks just wasn't there.
"I'm disappointed and the players are disappointed. I understand the frustration of the fans because they want us to win."
Middlesbrough manager Aitor Karanka:
"It was very, very important for us because we are losing points in the last minute.
"Not conceding late was important for the squad. It's important for our defenders and for the keeper to keep a clean sheet.
"(Ledesma) played very well. He's the kind of player who deserves to play.
"The team is starting to take shape. I've said since the first day I'm very happy with this team. I can see them improve but we just need to win the points."
- 01 Forde
- 02 Dunne
- 28 Malone
- 26 Abdou (Keogh - 73' )
- 05 Robinson
- 16 Beevers
- 07 Feeney
- 06 Trotter
- 27 McDonald Booked (Easter - 62' )
- 09 Morison
- 11 Woolford
- 03 Shittu
- 08 Easter
- 12 Lowry
- 17 Moussi
- 20 Keogh
- 21 Smith
- 43 Bywater
- 12 Given
- 08 Varga
- 03 Friend
- 33 Smallwood
- 26 Ayala Booked
- 22 Gibson
- 27 Adomah
- 18 Whitehead
- 23 Main (Jutkiewicz - 84' )
- 10 Emnes (Butterfield - 74' )
- 19 Carayol (Ledesma - 32' Booked )
- 06 Butterfield
- 09 Jutkiewicz
- 11 Ledesma
- 13 Konstantopoulos
- 14 Williams
- 15 Hines
- 38 Haroun
Ref: James Linington