The victory was Southampton's first in the league since Nov. 5, while defeat for West Ham continued their patchy run of form after a fine start to the season, with just one win in their last seven league games.
A lethargic opening from the home side allowed Southampton to take the lead after eight minutes when Mohamed Elyounoussi lashed home with his left foot from the edge of the box following a driving run from Kyle Walker-Peters.
West Ham created little going forward as Southampton keeper Fraser Forster remained largely untroubled during the first half.
"It's about time we won. We've been working really hard the past few weeks. In the second half West Ham took over a bit and they were the better team for about 20 minutes. Fraser [Forster] in goal was amazing today so credit to him and everyone," Elyounoussi said.
West Ham manager David Moyes turned to his bench after the break and substitute Michail Antonio made an instant impact when he headed home from close range in the 49th minute before Ward-Prowse restored the away side's advantage from the spot just after the hour-mark.
A revitalised West Ham hit back three minutes later through Said Benrahma after being played in by Jarrod Bowen, but Jan Bednarek grabbed the winner in the 70th minute when he deftly turned in a curling free kick from Ward-Prowse.
Southampton boss Ralph Hasenhuttl hailed his side's "brave" performance and praised the players for showing resilience.
"Huge win because our record here in the last five years is that we haven't taken a point here. We played well today it was the right thing to do we never stopped believing and scored three fantastic goals," he said.
"We had a bit of a push back but an excellent opening 15 minutes and we can't play that way for 90 minutes so it's normal but we played well."
The win moved Southampton up to 14th in the standings with 20 points from 18 games, eight points behind sixth-placed West Ham.