Three minutes later, Barnsley equalised when Hallfredsson's corner from the left caused problems in the Boro' defence and captain Steve Foster headed the ball home.
Barnsley's winning goal came in the 59th minute when Hallfredsson played the ball inside to Daniel Bogdanovic. His cross found an marked an unmarked Hugo Colace, who headed home from six yards.
The home side should have made the match safe 10 minutes from time but Bobby Hassell's cross from the right was too good for anyone to get a touch.
Robins said: "In the first half we couldn't get near them, it was difficult to contain them, we had to get them - that's why we pushed Bogdanovic up front.
"It was a better second half - we were determined to carry on our run and that's why we didn't let our heads drop. It's a great end to the year."
"That was only our fourth home win of the season, when I came here we only had one point and it shows how well the players have done since I came here.
"For us it was a real good test and a good three points. I gave the players Christmas Day off because of the weather, that's the first time I've done that and its paid dividends for us. We don't look beyond the next game.
He added: "For their goal Luke Steele came out too early, but in the second half he came for one and if he had waited their player would have nipped in.
"I thought our central defenders Moore and Fossie (Foster) were excellent when they went forward.
"Moore was unlucky to have his header cleared off the line but I was pleased for Fossie when his went in.
In the first half Middlesbrough were the better side and controlled the game.
They took the lead in the 24th minute through full-back Justin Hoyte, who picked up a loose ball on the left and saw his cross beat everyone - including Steele in the Barnsley goal.
Boro boss Gordon Strachan said: "It was a fluke.
He added: "We won the football match in the first half and they decided to turn it into a cup tie and then they won it.
"We were disappointed to lose the game but we couldn't match them in a different game."
The Scot added: "There was nothing wrong with the first goal and the second one was made by a good cross."