Solskjaer’s men had lost four of their previous five games in all competitions and could easily have suffered another damaging defeat to their chances of a top-four Premier League finish.
West Ham had a goal harshly ruled out for offside, hit the crossbar and saw David de Gea make a wonder save to deny Michail Antonio giving them a late lead.
“They played better than us, it is fair to say, I don’t think anyone will disagree,” said the Norwegian.
“We got away with it. Sometimes we have lost when we should have won, so over a season it evens itself out.”
Solskjaer left Marcus Rashford and Scott McTominay on the bench among five changes from the side that started Wednesday’s Champions League quarter-final, first leg defeat to Barcelona.
And he admitted the quick turnaround before facing Barca again in the Camp Nou on Tuesday had affected his team selection.
“Playing on Wednesday, and today and again on Tuesday played a major factor,” he added.
“We got away with it, got three points, in a few years no-one will remember how we played if we finished in the top four.
“We rested a couple, thankfully, we got through it and we will be ready for Tuesday. With a performance like this, we all know we will struggle in Barcelona, and we will have to improve.”
The victory lifted United up to fifth at the expense of Arsenal and to within two points of fourth-placed Chelsea.
Would you like to place a soccer bet? Click here to get started in 3 easy steps.