The Hammers edged a poor first half and went in ahead at the break thanks to a deflected effort from Angelo Ogbonna.
Arsenal failed to clear a corner properly which allowed Pablo Fornals to cross for Ogbonna to head past Bernd Leno via a deflection off defender Ainsley Maitland-Niles.
The Gunners hit back in the second half, scoring three goals in nine minutes to secure a much-needed victory.
Gabriel Martinelli side-footed Kolasinac's cross home for his first Premier League goal before Nicolas Pele curled a superb strike past goalkeeper David Martin to put Arsenal ahead.
The summer signing then crossed for Pierre-Emerick Aubameyang to volley the third and secure a first league win since the victory over Bournemouth on October 6.
Ljungberg named Aubameyang, Martinelli, Pepe and Mesut Ozil in an attacking starting XI against West Ham. The hosts made just one change to their team, bringing in Michail Antonio for Sebastien Haller:
Arsenal's plans were disrupted by an injury to Hector Bellerin in the warm-up which saw the Spaniard drop out and be replaced by Maitland-Niles.
After a cagey start, the visitors suffered another injury blow when full-back Kieran Tierney was forced off with injury after tangling with Antonio in the penalty area.
BBC Sport's Simon Stone offered some detail on the problem:
Arsenal saw plenty of the ball in the opening 30 minutes but despite all the attacking talent on show struggled to carve out any chances against the hosts.
Opta's Duncan Alexander highlighted their lack of threat:
West Ham managed to exploit Arsenal's defensive problems to break the deadlock on 38 minutes through Ogbonna.
The Gunners failed to deal with Robert Snodgrass's corner in from the left and the ball eventually fell to Fornals to stand up a cross for Ogbonna to head in from close range:
Snodgrass came closer to adding a second early in the second half with a deflected effort that bounced wide after more sloppy play from the Gunners, while Declan Rice tested Leno with a powerful effort from the edge of the penalty area.
Yet Arsenal equalised on the hour courtesy of some poor West Ham defending. Kolasinac was allowed to stride into the penalty area and pull the ball back for Martinelli to slot home:
The visitors' second goal arrived six minutes later and in some style. Pepe cut in from the right and curled a rising strike that flew past a helpless Martin and into the top corner.
Arsenal made the game safe three minutes later when Pepe took a backheel from Aubameyang and then returned the ball to the striker to volley home:
Victory ends a run of nine games without a win for Arsenal and moves the Gunners into ninth place in the table, while West Ham remain in trouble and are just a point off the relegation zone.
Arsenal play Standard Liege in the UEFA Europa League on Thursday and then welcome Manchester City to the Emirates on Sunday in the Premier League. West Ham's next game is on Saturday against Southampton.