The Dark Knight vs. the Films of 2012

Batman’s first inter-company crossover was in 1981 with Batman vs. The Incredible Hulk and, during 1996’s DC vs. Marvel miniseries, The Dark Knight took on Captain America with the fate of his entire universe at stake (he won), but it wasn’t until 2002 that JLA/Avengers had Bruce and his super friends meeting up with Earth’s mightiest heroes.
Written by Kurt Busiek with art by George Perez (who was originally going to draw a JLA/Avengers in the 1980’s), the four-issue miniseries has both superhero teams pitted against one another in a game orchestrated by Krona and the Grandmaster. Like in DC vs. Marvel, only one universe was supposed to survive.
Batman spends most of his time working with Captain America (unaware that they did battle just a few years earlier) and they even manage to form a bond over their respective lost sidekicks.

Outside of continuity, there’s also a 1997 Elseworlds one-shot by John Byrne that features both Batman and Cap teaming up during World War II.