The 22-year-old forward scored 16 goals for the Shrimps in last season's promotion campaign, including the winner from the penalty spot against Newport County in the League Two play-off final at Wembley in May.
Gomes was on Atlético Madrid's books as a teenager when living in Spain, before he moved to England with his family.
Morecambe spotted him playing for West Didsbury and Chorlton, signing him in 2018.
Morecambe manager believes their transfer window is closed for now
Morecambe firm backs Roman Fury - brother of Tyson Fury - as he prepares for debut fight
Morecambe youngster completes Sunderland move
Thomas' superb round is a Winn-er for Morecambe Golf Club in prestigious Clayton Trophy
Morecambe winger departs the club by mutual consent
The 2020/21 campaign was his breakthrough season in terms of regular first-team football, Gomes attracting plenty of interest - Rangers, Celtic and Preston all sent scouts to watch him.
After the play-off final, Morecambe took up an option of a year's contract on him and that enabled them to get a fee for Gomes rather than lose him for a lower youth compensation fee.
Now he has clinched a move to the Championship, joining Nathan Jones' side who finished 12th last season.
Morecambe director James Wakefield said: "We hugely appreciate the contribution that Carlos made to Morecambe FC and enjoyed watching his rapid development as a player under the club’s excellent coaching staff, within both the academy and the first team set up.
“We knew that we would not be able to secure his services beyond the 2021/2022 season and therefore we spoke to several football clubs that have been tracking Carlos’s progress.
"We were keen for him to move to a club at Championship-level with a proven track record of developing young players. Luton Town stands out in that regard, and a deal was struck that both clubs are happy with.
“Achieving our vision to be sustainable and competitive at League One level means making good decisions and, when appropriate, striking excellent deals that allow further investment into every aspect of the club. This is exactly that.
"We want Morecambe FC to become renowned for developing young talents like Carlos and achieving the right balance between enjoying their contribution on the football pitch before wishing them well as they progress up the pyramid with clubs that have the right ethos.
“Everyone at the club wishes Carlos all the best at Luton. He is a player with an incredibly bright future, and we are proud to have played such a key role in his development."
Posting a goodbye message to Morecambe on Twitter, Gomes said: "It hurts saying goodbye but all I can say is that I couldn't have been the person that I am now without the support of the fans, my team-mates, my family and the club.
"I have nothing but gratitude towards this club and this town.
"However I believe that the time has come to open a new stage in my life."
He continued: "Morecambe has won my heart as well as my family's, that's why I would like to say thank-you o the board, my team-mates, my coaches, the managers, for making the next step possible.
"Last but not least the fans who have showed me love since the day I walked in. Once a Shrimp always a Shrimp."
Thanks for reading. If you value what we do and are able to support us, a digital subscription is just £1 per month for the first two months. Try us today by clicking here