In both deals, the Guardians will either get a player to be named later or cash considerations.
The club also signed catcher Sandy Leon to a minor league contract with an invitation to spring training.
Ramirez, 27, hit .268/.305/.398 with seven home runs and 41 RBIs in 99 games this past season. The Cubs will be his third team in four big-league seasons.
Mejia, 25, went 1-7 with an 8.25 ERA in 17 appearances (11 starts) in 2021. He struck out 47 in 52 1/3 innings in his rookie season.
Leon, 32, hit .183 in 83 games last season for the Miami Marlins. He’s a career .212 hitter with four different teams. He won a World Series with Boston in 2018.