The 21-year-old was close to joining the Eagles last summer but they instead opted to bring in Blues team-mate Michy Batshuayi on a temporary deal.
Now Gallagher has sealed a move to Selhurst Park and becomes new boss Patrick Vieira's fifth signing.
He said: "I'm buzzing to be here. I can't wait to get started, I'm happy to get the deal over the line.
"I spoke to the manager, I liked what he said, I liked how he wants to play, how he wants me to play and how he wants the team to play. I feel like I can learn from him and the players around me."
Gallagher spent last season on loan at West Brom, where he made 32 appearances and impressed for both Charlton and Swansea during the 2019-20 campaign.
"We very much look forward to him joining the squad as we continue to build towards the new season."