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
An out-of-sorts Davies was withdrawn for winger Kamil Grosicki at the interval as Silva looked to inject some vigour into his side and not for the first time this season his tactical switch paid dividends
Hull's best move of the match saw Lazar Markovic link well with Grosicki and the latter slipped in a marauding Robertson to run on into the area and bury a low left-footed shot into the bottom corner for a 53rd-minute equaliser
Carroll's thumping header was then instinctively saved by Jakupovic, but the Tigers had stirred at last and all of a sudden West Ham looked rattled
Hull threatened again when Alfred N'Diaye's right-footed effort hit a post and Grosicki fired the rebound wide
Both sides chased the winner
Feghouli headed Lanzini's cross wide and then spurned another chance when firing off target, but it was Hull who cashed in on their momentum
Silva sent on midfielder Markus Henriksen and Shaun Maloney for Abel Hernandez and N'Diaye with 10 minutes left and three minutes later his side snatched the lead
Grosicki curled in a corner from the left and Ranocchia rose 10 yards out at the near post and directed a fine header beyond Randolph into the opposite corner
Carroll and team-mate Sam Byram were both off target in the closing stages as West Ham chased an equaliser , but Bilic's side fell short and are now just six points above the drop zone
Source : PA