Magic is one of the areas that Batman only has some expertise in, as magic is ever changing and is never what it appears to be. Thankfully, some of his allies are among the most powerful magicians in the realms. Case and point is Arthur Kent, known to many as Doctor Fate.
Doctor Fate is a Lord of Order, one of a group that is dedicated to protecting the balance in the universe. To do so, he's been granted the use of a helmet that is endowned with a Lord of Order, allowing him to cast incredibly powerful spells, enchantments, and whatever else he may need to help save the world.
Batman has worked with Doctor Fate many times, including in three differnet animated series. Fate can always be counted on for expertise in the field of magic, and if he doesn't know something, he usually knows where he can find out about it. A thirst for knowledge and a desire to keep the world at peace is what makes him such a great ally.