Italian defender Ranocchia, signed on loan from Inter Milan in January, headed home in the 85th minute to secure Hull a 2-1 win at the KCOM Stadium after Andrew Robertson's strike after the break had cancelled out West Ham striker Andy Carroll's landmark opener.
Victory for Hull was their fourth in five unbeaten league games at home under head coach Marco Silva and lifted them level on points with relegation rivals Swansea, who play Middlesbrough on Sunday, while West Ham slumped to a fourth straight defeat.
The visit of West Ham had been billed as the return of winger Robert Snodgrass, sold to the Londoners for £10.2million in January, but the Scot made little impact and was withdrawn in the second half.
Snodgrass was booed every time he was on the ball, but almost silenced the Tigers fans in the 13th minute when he headed Sofiane Feghouli's bouncing right-wing cross straight at goalkeeper Eldin Jakupovic.
Neither side had mustered an effort on goal until that point, but West Ham took the lead with their next chance five minutes later.
Hull skipper Curtis Davies misjudged his headed clearance from Aaron Cresswell's excellent cross and, as the ball dropped invitingly for Carroll six yards out, the big number nine kept his composure to side-foot home on the volley for his 50th Premier League goal and seventh of the season.
Jakupovic denied West Ham a second soon after when he turned away Manuel Lanzini's dipping, low shot from outside the area.
Hull tried to rally and only some desperate defending denied Oumar Niasse a shooting chance in the area after Sam Clucas' clever backheel, but the home side failed to trouble Darren Randolph at all in the first period.
Read the full article on eurosport.co.uk: Hull boost survival hopes with win over West Ham