WASHINGTON — President-elect Donald J. Trump said on Thursday he had chosen James N. Mattis, a hard-charging retired general who led a Marine division to Baghdad during the 2003 invasion of Iraq, to serve as his secretary of defense.

Mr. Trump made the announcement at a rally in Cincinnati, calling General Mattis “the closest thing we have to Gen. George Patton.”

General Mattis, 66, led the United States Central Command, which oversees military operations in the Middle East and Southwest Asia, from 2010 to 2013. His tour there was cut short by the Obama administration, which believed he was too hawkish on Iran.

But his insistence that Iran is the greatest threat to peace in the Middle East, as well as his acerbic criticism of the Obama administration’s initial efforts to combat the Islamic State in Iraq and Syria, made him an attractive choice for the incoming president.