Slaven Bilic's future had been under question with the Hammers reeling from five consecutive league defeats, but he will have done his chances of hanging on to the hotseat no harm with his side's performance and result against the Swans.
The hosts were bright from the off and took a deserved lead just before half time when Cheikhou Kouyate collected a Robert Snodgrass pass, strode into space and rifled a ferocious strike past Lukasz Fabianski from 25 yards out.
Swansea, desperately trying to avoid a fifth straight away loss, improved in the second half following a double substitution by Paul Clement at the break, with Luciano Narsingh coming closest to an equaliser for the visitors in the 82nd minute, but his powerful strike went just over.
Andre Ayew had two late opportunities to clinch the points against his former club but both were snuffed out by the impressive Fabianski, though the squandered chances mattered little as West Ham clung on and extended Swansea's miserable run away from home.
The result puts 14th-placed West Ham on 36 points, eight ahead of 18th-placed Swansea, with both teams having just six games left this season.