Swansea made Andre Ayew their first signing of the January transfer window as the Ghana striker returned to the Liberty Stadium in a club-record deal.
Ayew left Swansea for West Ham in the summer of 2016 for £20.5million.
The 28-year-old returns for a record fee, understood to be £18m and possibly rising to £20m.
The move reunites him with his brother Jordan as the pair were previously together at Marseille.
"Swansea City have re-signed Andre Ayew from West Ham United in a club-record deal,'' said a statement on the official club website. "Ayew has put pen to paper on a three-and-a-half-year contract at the Liberty Stadium after the Swans agreed an undisclosed fee with the Hammers.''
He first joined Swansea from Marseille in June 2015 and scored 12 goals in 35 appearances before joining West Ham.
Ayew scored 12 goals in 50 games in east London but Hammers boss David Moyes was happy for him to leave the club as he felt his squad was imbalanced with too many forwards.
Swansea also confirmed the signing of 6-foot-4 centre-back Jack Withers, who signed an 18-month deal from Boston United and will return to the club to spend the rest of the season on loan.