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 £18million and possibly rising to £20million.
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 have taken 10 points from 15 under new manager Carlos Carvalhal to boost their hopes of avoiding relegation from the Premier League.