Hugill, who was born on Teeside, made just three appearances for the Hammers after signing from Preston North End in January.
"It's been a long time coming and I'm excited to get started," said Hugill. "It's big move coming to my hometown club, and hopefully I'll do myself justice.
"It's something I've grown up wanting to do is play for Middlesbrough. I'd break my back to be here, now I want to show people what I can do."