The visitors, who lost 2-0 seven days ago, were pegged back twice before Harrison scored the pick of his three goals with a neat chip over Lukasz Fabianski as Leeds made it consecutive league wins for the first time this season.
Harrison opened the scoring with a fierce strike in the 10th minute but West Ham recovered from their lacklustre start to equalise through the in-form Jarrod Bowen.
Leeds took the lead again before the interval as Harrison sneaked in at the back post to convert off his thigh from Luke Ayling's downward header following a corner.
Pablo Fornals scored his first goal since November to draw the Hammers level for a second time in the 52nd minute, but Harrison sealed victory eight minutes later.
Leeds could have had an even healthier lead but Mateusz Klich's effort was ruled out as it brushed an offside Rodrigo on its way in.
West Ham remain fourth but the group of clubs in the chasing pack all have games in hand. Fifth-placed Arsenal are two points behind having played two games fewer.
Harrison said afterwards: "Delighted to get a hat-trick. It is an amazing feeling to score and when you get three even better. I am just really happy to take part in the win.
"The last week we have been working super hard after the defeat against West Ham in the FA Cup. We wanted to show a different side to us. We were able to control the game a bit and get three points.
"We have been really unfortunate with injuries but against adversity we always work hard. The young lads have done that coming in and shown their talent. It has been good to come through a tough period.
"Hopefully we can go on a good run of form between now and the end of the season."
Need a VPN? Or seeking to switch? Then support Tribal Football by clicking here to sign up with our official partners NordVPN. Not only will you receive the best VPN experience, but also great discounts by signing up via Tribal Football. Thanks for your support!