In response to a 2017 request from the Pentagon, Twitter kept online a network of accounts that the U.S. military used to advance its interests in the Middle East, according to internal company emails that were made public Tuesday by The Intercept, a nonprofit publication.

A counterterrorism division at Twitter knew about the arrangement, but others did not, five people with knowledge of the matter said. When it became more widely known within the company, executives rushed to undo it. But they struggled with whether to publicly disclose the military-run Twitter accounts, the people said.

Some of the accounts were removed, but others remained online for years. Twitter eventually disclosed the U.S. influence campaign this year.