Analogical reasoning is a cornerstone of human cognition, but the extent and limits of analogical reasoning in animals remains unclear. Recent studies have demonstrated that apes and monkeys can match relations with relations, suggesting that these species have the basic abilities for analogical reasoning. However, analogical reasoning in humans entails two additional cognitive processes that remain unexplored in animals. These include the ability to (1) flexibly reencode the relations instantiated by the source domain as a function of the relational properties of the target domain, and (2) to match relations across different stimulus dimensions. Using a two-dimensional relational matching-to-sample task, the present study demonstrates that these two abilities are in the scope of baboons, given appropriate training. These findings unveil the richness of the cognitive processes implicated during analogical reasoning in nonhuman primates and further reduce the apparent gap between animal and human cognition.