The 33-year-old Wilson has recorded 111 direct goal contributions in 239 Premier League appearances, including 49 in 130 matches for Newcastle, where he could not come to terms on a new contract.
He has represented England nine times, scoring twice.
"I'm thrilled to be joining a huge football club like West Ham—a club that shares my passion for hard work, dedication, and striving for success, so I'm excited to be part of it," Wilson stated.
Wilson joined Newcastle in September 2022 and achieved his best Premier League season with 18 goals in 2022-23, a year that also saw him play for England at the World Cup in Qatar.
He participated in only 18 league matches last season due to injuries.
"He is a proven, seasoned Premier League striker, known for his strong work ethic and impressive goal-scoring record," West Ham coach Potter remarked.
"He also possesses excellent character and personality, which is a crucial factor, and something we prioritize in our player recruitment."