Nolberto Solano converted a 43rd minute penalty after Kevin Kilbane had brought down Craig Bellamy and but for goalkeeper Thomas Sorensen the Magpies would have not been forced to endure a couple of late scares.
Kevin Kyle headed into the net in the 90th minute only for referee Steve Bennett to rule the Scottish international had fouled goalkeeper Shay Given in his attempts to avert a 13th successive defeat.
O'Brien was forced out of the action with a suspected broken nose after an 18th minute collision with Kyle and an even bigger blow for the visitors was the loss of leading scorer Shearer with an ankle injury.
Shearer had the ball in the net after less than two minutes only to be pulled up for pushing but it took a brilliant one-handed save by Given to keep out a piledriver from the recalled David Bellion.
Sorensen denied Bellamy and Solano before the visitors' goal gained a charmed life in the 40th minute. Aaron Hughes headed a Sean Thornton corner against his own bar and from the resultant corner, Michael Proctor's close-range effort was scrambled off the line.
Three minutes later United took the lead and only the heroics of Sorensen, destined to become a casualty of the Black Cats summer clear-out because of financial problems, kept his side in with a chance.
The Danish international saved with his legs from Bellamy, Solano mis-kicked in front of goal and substitute Shola Ameobi stumbled over the ball when forcing his way clear.
Sunderland manager Mick McCarthy claimed his side could not have done any more and had done enough to at least end the depressing run of defeats.
"There was a lot of passion and quality and I feel hard done by that we did not get something out of the game,'' he said. "We had a goal disallowed in the 89th minute and I didn't see too many complaints from their players or their bench.
"Yes I am bemoaning my luck and whinging that we didn't get a result but the last few performances have given me something to build on for next season.
"Did we look like a team that has lost 13 games in a row? How we get out of it I don't know but we didn't look like a rock-bottom team with just 19 points.''Newcastle moved back into third place after a first win in five matches and manager Sir Bobby Robson hopes derby rivalry will soon be resumed.
"I hope they get back to winning ways and that we have this games in two years' time,'' he said. "This was a massive win for us and Sunderland have probably played their best for weeks and weeks.
"It was a typical derby that went to the end. We had no cushion, they wouldn't let us settle and went at us from the first minute.''