The Justice Department filed charges late Tuesday against bombing suspect Ahmad Khan Rahami, saying that he ordered many of his explosive components online and raged in a journal against what he viewed as U.S. attacks on Muslims.

Mr. Rahami, who is suspected of setting off homemade bombs in New York and New Jersey last weekend, including one in Manhattan’s Chelsea neighborhood that injured 31 people, was captured on Monday after a gunfight with police in Linden, N.J. The charges filed in Manhattan federal court included use...