The former Marseille winger and son of one-time African player of the year Adebi Pele, joined the Hammers for a fee of £20.5million (24 million euros).
"I am very proud and happy to be at this magnificent Club," the 26-year-old told West Ham's website.
"The Club have a lot of ambition and have a great manager. They want to become a bigger Club every year and with the new Stadium and a new training ground, you can feel they are moving onto another level and I want to be part of this project," he said.
Ayew scored 60 times in over 200 appearances at French outfit Marseille before joining Swansea last season.
Playing a key role in their 2014 World Cup campaign, Ayew has extensive international experience with Ghana.