From Star Trek: Theurgy Wiki
Section 31 was the name of an officially-nonexistent and autonomous clandestine organization which claimed to protect the security interests of United Earth and, later, the United Federation of Planets. Loosely speaking, it was Starfleet's black-ops division, operating separately from and usually without the knowledge of Starfleet Intelligence (though it often recruited members of Starfleet Intelligence). Section 31 was also somewhat comparable to the Romulan Tal Shiar or Cardassian Obsidian Order – unlike these other organisations, however, Section 31's very existence was a deeply buried secret, known only to a handful of people beyond its own membership.
Perhaps Section 31's darkest aspect was that, while it had existed since the beginning of Starfleet, it was practically autonomous, having operated for over two centuries with no oversight or accountability whatsoever, even free to kill those it deemed a threat to Federation interests at its own discretion. Some high-ranking Starfleet admirals and intelligence personnel at times seemed to be vaguely aware that Section 31 existed, though giving them only very broad objectives.(citation needed • edit) At other times, Section 31 appeared to be an outright puppet master to Starfleet, directing the actions and even overall political policies of the Federation itself. Source: Memory Alpha