The Hammers were keen to get a deal over the line for the 32-year-old, who featured three times for Colombia at this summer's World Cup.
West Ham's ninth and final summer signing told the club's official website: "I'm very happy to be here. I'm very excited and looking forward to achieving lots.
"I decided to come here because, first, it is the Premier League, second, it's a beautiful club and the fans are always helping the club and, third, for me it's an amazing opportunity and an amazing project the club are leading, being ambitious and keen to achieve good things.
"I'd like to thank all of the people, the whole club, for having me."
Sanchez, a veteran of five major international tournaments, has previously spent two seasons in the Premier League with Aston Villa between 2014 and 2016.