Sheringham came off the bench to net with his first touch after 65 minutes before the assistant on the far side ruled Chris Riggott had deflected the ball over the line - despite replays showing goalkeeper Mark Schwarzer had kept it out.
• McClaren 'devastated'
While West Ham were just about good value for their first Barclays Premiership win in four attempts, Steve McClaren's men again suffered from their European endeavours in midweek, failing to really test opposing keeper Shaka Hislop, with a late header from substitute Franck Queudrue proving little consolation.
After a promising opening from the home side, they almost pressed the self-destruct button on eight minutes.
A loose pass along the West Ham back-line from Anton Ferdinand put Danny Gabbidon in trouble, and he brought down Gaizka Mendieta some 25 yards out as the Boro midfielder looked to skip clear.
However, the Spaniard's strike from the resulting free-kick was horribly high and wide.
Mendieta was felled again, this time by Paul Konchesky, in a similar position. Fabio Rochemback took responsibility himself, but could only drive a low effort into the wall.
Mendieta then floated a deep cross over from the right, which found its way through to Massimo Maccarone at the far post, but the striker's header flew high into the stands.
West Ham had their first notable attack after 16 minutes when Yossi Benayoun twisted his way into the penalty area, and struck a low effort goalwards, which was blocked by an alert Gareth Southgate.
Bobby Zamora - preferred in attack to Sheringham - had a great chance to open the scoring after 21 minutes when a fine pass from the impressive Benayoun opened up the Boro defence.
The ball dropped to the Hammers striker ahead of his markers on the edge of the penalty area, but he could only guide a tame, first-time effort straight at Schwarzer.
In the 25th minute, Southgate had to be replaced following an awkward fall, with Queudrue coming on.
West Ham were pressuring well, and Hayden Mullins flashed an effort just wide of the right-hand post when the ball broke to him 15 yards out.
Hammers captain Nigel Reo-Coker thought he had opened the scoring on 31 minutes when he back-heeled Marlon Harewood's low centre in from close range, but was flagged offside - which looked a correct, if marginal, call.
Then, on the counter-attack, Rochemback flashed a low effort across goal after getting in down the left channel, which Hislop did well to scramble away.
With four minutes to go before half-time, Mendieta found some space around 25 yards from goal, and was unfortunate to see his well-struck shot drift just wide of Hislop's left-hand post.
George Boateng's 15-yard strike from a well-worked corner on the right was blocked bravely by Ferdinand in stoppage time.
Following a slow start to the second half, Rochemback, on 52 minutes, clipped an effort goalwards from the edge of the area but Hislop was well placed to collect comfortably.
Queudrue then flashed a deep centre from the left across the area, which was just too far ahead of Maccarone.
At the other end, Benayoun could not guide Konchesky's cross from the left on target, his header flying wide from 10 yards.
The Hammers upped the tempo as the hour approached, another centre, this time from Matthew Etherington on the right, flying across the area with no-one able to make a vital connection.
Determined runs by Harewood and then Zamora on the edge of the area, saw the ball break to Benayoun.
The midfielder weaved his way towards the by-line, drew the keeper and slotted the ball back goalwards, but Queudrue was on hand to clear off the line.
After 65 minutes, Sheringham was sent on for Zamora - and with his first touch, the former England man put West Ham ahead.
Konchesky made ground down the left flank, and cut the ball back into the penalty area, where Sheringham was in the perfect position to slot home a low strike, which took a slight deflection past Schwarzer.
The Hammers went 2-0 up in controversial fashion with 15 minutes left.
Konchesky whipped in a free-kick from the left, which deflected off Riggott. Although wrong-footed, Schwarzer clearly got his hands down to make the save on the line but the assistant referee on the far side ruled the ball had gone in - much to the disbelief off the whole Boro side and bench.
Boro pulled a goal back with three minutes left when Queudrue headed in a corner from the left, but West Ham closed out the remainder of the match without much concern.
Boro 'devastated'
Furious Middlesbrough manager Steve McClaren maintained goal-line technology
must be introduced to get the 'right result' after assistant referee Ralph
Bone handed West Ham a controversial second goal in their victory at Upton
Park.
McClaren bemoaned: 'We are devastated by that decision. It is a big
decision and a wrong decision. Ultimately it has cost us the game.
'I don't know how he has given it, because from the angle I have seen, and
the angle of Mark Schwarzer's body from where the linesman was positioned, it is
an impossibility to make that kind of decision straight away in a matter of
seconds.
'You could see by the reaction of all the players - they knew it was not a
goal, yet somehow the only man in the stadium on the field who could give that
decision gave it.
'There are things you can't control - linesmens' decisions and referees'
decisions. But when it is like that, it is harder to take.'
McClaren insisted: 'I have got every sympathy with referees and linesmen in
the modern game, but this question of 'over the line' has had too many
implications over the past few seasons to be just dismissed, and relying on
human error to make wrong decisions when we have got technology where decisions
like that don't have to be wrong - they can be sorted out.
'I looked at it 20 seconds after the incident and could see clearly it was
not a goal.
'All it would take was 20 seconds - by the time all the protests died down,
it must have been three or four minutes. Everything could have been solved by
then.
'Other sports are using technology, and it is helping and aiding them. If it
helps you get the right result then so be it.'
McClaren added: 'You get wrong decisions, and decisions which go your way.
You have to take it and take it with dignity. We had to do that.
'All we said at the end was, no blame on the referee, but the linesman got it
wrong. Have a look at it and he will see.'
Hammers' boss Alan Pardew admitted his side had been fortunate with the
decision of the assistant referee to go their way and hand the home side a
two-goal cushion.
'I have seen and have to be honest - it was not a goal, no way,' admitted
Pardew.
'But you get breaks, and it was a fortunate break for us because it gave us a
little bit of a cushion and with conceding near the end, it could have cost us
the points.
'In some ways I felt we earned it, and sometimes in football when you don't
deserve a break, you get one.'
Pardew would also be in favour of using technology, if it was did not 'stop
the flow of the game'.
He said: 'If they could do it in an instant, then I would be happy with
that.
'If you are 0-0 in a static game, and were waiting five minutes for a
decision, which was not given, it would bring the house down.'
West Ham recorded a first victory in four attempts to climb back into the top
10 of the Barclays Premiership.
'I thought it was our best performance of the season,' the Hammers manager
declared. 'We went about our business in a pleasing manner because Middlesbrough don't
make it easy.
'In the second half, we had got a little bit stale, and the decision to bring
Teddy on was an easy one - probably most people in the ground would have made
it.'
Pardew added: 'If you need something, what better player is there to bring on
than him?'
Boro were playing their second match of the week after their UEFA Cup win on
Thursday night, but lost captain Gareth Southgate with, according to McClaren, a
groin injury during the first half.
The centre-back - who had left the field with what appeared to be a cut head -
looks set for a couple of weeks out.
'It was always going to be a tough game coming here and started the game ever
so well, but then had to re-adjust because it was a big loss when losing
Southgate,' said McClaren, who had defender Stuart Parnaby unavailable today.
'I always felt we had a chance, even at 1-0 down. Credit to the players for
their attitude all the way through, they kept going to the end. We have got to bounce back from this - we have done it before and will do it again.'