The 28-year-old spent the second half of last season on loan at Lyon, scoring three goals in 12 league appearances.
Benrahma's loan deal included an option to buy, and is has now been confirmed by West Ham that Lyon have exercised an option to make the move permanent for a reported €14m (£11.9m).
The Algeria international signed for the Hammers from Brentford in October 2020 and went on to make 155 appearances in Claret and Blue, scoring 24 goals and providing 20 assists.
Benrahma's most memorable moment in a West Ham shirt was at the end of the 2022-23 campaign when he scored a penalty in the Europa Conference League final win over Fiorentina.
Johnson, Mubama also depart West Ham
Meanwhile, West Ham have also confirmed that academy graduates Ben Johnson and Divin Mubama will leave the club when their respective contracts expire at midnight on June 30.
Johnson, 24, departs after 17 years as a Hammers player, having originally joined the club at the age of seven, and made a total of 109 first-team appearances in all competitions.
The versatile defender, a two-time Young Hammer of the Year, started eight games in West Ham's triumphant Conference League campaign in 2022-23, and then played 22 times in all tournaments last season, but only seven of those outings were starts.
Mubama, meanwhile, joined West Ham at the age of eight and was part of the academy side that won the FA Youth Cup and Under-18 Premier League South title in 2022-23, ending the campaign by being named Mark Noble Young Hammer of the Year.
The 19-year-old made his senior debut in November 2022 and went on to make 18 first-team appearances for West Ham in all competitions, scoring just once in a Conference League win over AEK Larnaca in March 2023.
Johnson to remember West Ham spell "with fondness and a lot of love"
West Ham have released a statement from Johnson following his departure, which read: "Hello everyone, Thank you to everyone associated with West Ham United for supporting me over the last 17 years and developing me into a first-team player.
"I have been blessed to have come through the Academy of Football and to play for the first team in the Premier League, domestic cups and in European competitions.
"I just want to be known and remembered for my time at West Ham for having played with a smile on my face and having really enjoyed my football. That's really important to me.
"I would say the most special memory I have is winning the UEFA Europa Conference League. To be involved in a European trophy win doesn't come around frequently, so to be around and be part of it, and to be able to achieve that with West Ham was incredible.
"My dreams were exceeded by what happened two seasons ago and I'm just so, so pleased I did it as a West Ham player. I'll never forget that night.
"West Ham will always be a part of my life which I'll remember with fondness and a lot of love. I've developed into a young man and better player because of West Ham, so finally a huge thank you to the club! See you all soon."
Johnson is set to continue his career in the Premier League as he is reportedly closing in on a move to newly-promoted Ipswich Town.