Wilfried Bony had given the visitors the lead against the run of play with a smart first-time finish from Jefferson Montero’s pass, but Carroll powered home his first goal since March to send the sides in level at the break.
The England striker doubled his tally when he headed home a Stewart Downing corner on 66 minutes and Swansea were reduced to 10 men two minutes later when Lukasz Fabianski was sent off for rushing out of his area and denying substitute Sakho a clear goalscoring opportunity.
Garry Monk will be frustrated to see replays that indicated the West Ham forward handled the ball shortly before he was tripped and it was Sakho who completed the scoring three minutes from the end with a powerful shot past substitute goalkeeper Gerhard Tremmel.
Sam Allardyce opted to pair Carroll with Enner Valencia up front for the match and West Ham started brightly with Downing playing at the front of a midfield diamond behind the strike duo.
The home fans claimed two early penalties when Carl Jenkinson’s cross struck the elbow of Ashley Williams before Downing went down under a challenge from Leon Britton. Referee Chris Foy was unmoved on both occasions.
Kevin Nolan forced a smart save from Fabianski after a clever free-kick from Downing in the 18th-minute and moments later was made to pay for his miss as Bony opened the scoring.
Gylfi Sigurdsson played a clever ball in to Montero on the Swansea left, the Ecuador international getting in behind Jenkinson and rolling the ball back to Bony, who beat Adrian with a crisp side-footed shot from inside the six-yard box.
The home team were visibly rattled and Swansea looked to double their lead when Sigurdsson and Bony tried their luck from range, but both failed to beat Adrian.
Carroll looked to be the main outlet for West Ham throughout the first half and it was the big Englishman who found the equaliser with a trademark header.
Jenkinson delivered an inch-perfect cross from the right and Carroll peeled away from his marker and looped the ball back across goal and over Fabianski into the net.
The goal buoyed West Ham, who threw on top scorer Sakho for Valencia at half-time and started the second period in a positive mood, looking for impressive full-back Jenkinson to break down the right at every opportunity.
But it was Swansea who had the first big chance of the half when Montero broke and fed Bony, who got the ball out of his feet and smashed a ferocious shot onto Adrian’s crossbar.
The game was then turned on its head in a dramatic two-minute spell as Carroll put West Ham into the lead before Swansea were reduced to 10 men.
The big striker jumped to powerfully head home a Stewart Downing corner on 66 minutes, despite the best efforts of Leon Britton on the line.
The shell-shocked visitors then saw their goalkeeper sent off when Sakho raced through on goal and Fabianski rushed out of his area, only to impede the West Ham striker.
Sakho carried on and struck the post from a tight angle, but referee Foy decided a clear goalscoring opportunity had been denied and he sent Fabianski for an early bath. However, Swansea boss Monk will not be happy to see replays suggesting Sakho may have handled the ball with his left arm shortly before the contact.
Sakho hit the woodwork once again when he shot low across substitute goalkeeper Tremmel instead of crossing to strike partner Carroll, who was screaming for a hat-trick chance at the far post.
But Sakho did eventually score three minutes from time when a long ball was flicked on by Carroll in the centre circle and he rushed past Richards before producing a powerful finish to beat Tremmel.
The result sees West Ham complete a hat-trick of wins this week and climb above Manchester United and Southampton into third place.
West Ham: Adrian (6), Jenkinson (8), Tomkins (6), Reid (6), Cresswell (7), Kouyate (6), Song (6), Downing (7), Nolan (6), Valencia (5), Carroll (9)
Used subs: Sakho (7), O’Brien (5), Collins (5),
Swansea: Fabianski (4), Rangel (6), Bartley (7), Williams (7), Richards (6), Britton (6), Ki (5), Routledge (5), Sigurdsson (6), Montero (7), Bony (8)
Used subs: Gomis (5), Tremmel (5), Dyer (5)
Man of the match: Andy Carroll