Affleck, 41, and filmmaker Zack Snyder will create an entirely new incarnation of the Batman character for Snyder's as-yet-untitled project, which is to open July 17, 2015, the studio said.
Cavill, 30, and Snyder previously worked together on the blockbuster Superman flick "Man of Steel."
Affleck's casting was announced late Thursday by Greg Silverman, the studio's president of creative development and worldwide production, and Sue Kroll, president of worldwide marketing and international distribution.
"We knew we needed an extraordinary actor to take on one of DC Comics' most enduringly popular superheroes, and Ben Affleck certainly fits that bill, and then some. His outstanding career is a testament to his talent and we know he and Zack will bring new dimension to the duality of this character," Silverman said in a statement.
"Ben provides an interesting counter-balance to Henry's Superman," Snyder said. "He has the acting chops to create a layered portrayal of a man who is older and wiser than Clark Kent and bears the scars of a seasoned crime fighter, but retain the charm that the world sees in billionaire Bruce Wayne. I can't wait to work with him."
"We are so thrilled that Ben is continuing Warner Bros.' remarkable legacy with the character of Batman," said Kroll. "He is a tremendously gifted actor who will make this role his own in this already much-anticipated pairing of these two beloved heroes."
Christian Bale, 39, most recently played Batman on the big screen in writer-director Christopher Nolan's trilogy -- "Batman Begins," "The Dark Knight" and "The Dark Knight Rises," but both Bale and Nolan have said they are ready to move on to other projects.
Affleck, whose film credits include "Good Will Hunting," "Chasing Amy," "Armageddon," "Daredevil" and "Dogma," won an Oscar this year for directing "Argo."
Celebrity Breakups and divorces of 2014 [PHOTOS]