SAN FRANCISCO — Facebook said on Wednesday that it had banned Myanmar’s military and military-controlled state and media entities from its platforms, weeks after the military overthrew the country’s fragile democratic government.

The move plunged the social network directly into Myanmar’s post-coup politics — and left little question that it was picking sides in a pitched political battle.

Facebook acted after facing criticism for years over how Myanmar’s military has used the site, including to incite hatred against the country’s mostly Muslim Rohingya minority group. Since the coup earlier this month, which ousted the civilian leader Daw Aung San Suu Kyi and returned Myanmar to full military rule, the military has repeatedly shut off the internet and cut access to major social media sites, including Facebook.

The social network took the Myanmar military’s main news page and another state TV network page offline a few days ago. It also took down the official accounts of senior Myanmar military leaders who were linked to the Rohingya violence in 2018. But plenty of other military-linked pages were still online.

Now, in taking further action, Facebook has made it clear that it is making a political judgment. In a statement, the company said it was banning “remaining” accounts linked to the military because the coup was “an emergency.”

“Events since the February 1 coup, including deadly violence, have precipitated a need for this ban,” the company said. It added that the risks of letting the Myanmar military remain on Facebook and Instagram “are too great.” It said the military would be barred indefinitely.

The action underscores the difficulties Facebook faces over what it allows on its site. Mark Zuckerberg, Facebook’s chief executive, has long championed freedom of speech above all else, positioning the site as merely a platform and technology service that would not get in the way of governmental or social disputes.

But Mr. Zuckerberg has been increasingly scrutinized by lawmakers, regulators and users for that stance and for allowing hate speech, misinformation and content that incites violence to flourish on Facebook.

Over time, Facebook has become more activist over what is posted on its platform, especially in the past year with the U.S. election. Last year, it cracked down on pages and posts about the QAnon conspiracy theory movement. And last month, Facebook barred then-President Donald J. Trump from using the service, at least through the remainder of his term, after he urged his supporters to take a stand against the results of the election, leading to an insurrection at the U.S. Capitol. Mr. Trump remains unable to post on Facebook.

Many of these moves have been too little, too late, critics have said.