No financial details were given but media reports have suggested the deal, which includes an option for a further two years in the club's favour, is worth a reported 15.5 million pounds plus extras.
Carroll, the club's top scorer in 2012/13, underwent a stringent medical at the east London club after injuries limited him to 24 games last season.
"The marquee signing represents a significant step for the Club as they prepare to move to the 54,000-seater Olympic Stadium in 2016, with Carroll set to play a central role having committed his long-term future to the Hammers," West Ham said on their website.
The 24-year-old was loaned to West Ham in August 2012 as Liverpool changed their playing style under manager Brendan Rodgers.
A heel injury in West Ham's final game of the season meant Carroll missed England's recent friendlies against Ireland and Brazil.
The towering forward became Britain's most expensive player in January 2011 when Liverpool signed him from Newcastle for 35 million pounds on transfer deadline day.
"It's fantastic for me to be here. I really enjoyed last season, and that shows in me coming back and making it permanent," said Carroll.
"Since the end of the season I've had a lot of time to think, I've missed it and that's why I'm back. Getting promoted the season before last, then finishing where we did - we did great, and it can only get better for us."
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.