The 21-year-old spent the second half of the 2017-18 campaign on loan at Barnsley, making eight appearances in the Championship.
Birmingham are able to sign five players this summer, albeit without a fee, after having a transfer embargo lifted by the EFL.
"I'm buzzing. It is a massive club to be at," Mahoney told the official Blues website.
"To have the opportunity to come here and hopefully play some games, it was something I couldn't turn down. I'm just excited to hit the ground running and meet the lads."