
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.
History
22nd century
The organization’s title came from the original Starfleet Charter, Article 14, Section 31, which allowed for extraordinary measures to be taken in times of extreme threat. At some point before 2151, a young Ensign Malcolm Reed was recruited by Section 31 through former Starfleet Security officer Harris. By the time Reed was posted to Enterprise NX-01, he was no longer actively involved in covert operations.

However, in late 2154, when Reed was investigating the kidnapping of Doctor Phlox, he was contacted by Harris again. Harris’ organization had entered into a secret agreement with Klingon Fleet Admiral Krell, in which Harris facilitated Phlox’s forcible transportation to a Klingon colony to help in finding a cure for the Klingon augment virus in exchange for a mutually beneficial alliance.
Harris ordered Reed to slow down Enterprise‘s investigation until Phlox could develop a cure. Reed complied, but his tampering was discovered by Captain Jonathan Archer and Commander T’Pol, and Reed was thrown in the brig.
T’Pol reconstructed Reed’s communication logs and discovered that he had been in contact with Harris. When confronted with this information, Reed confessed that he had been following Harris’ orders. Later, Archer had Reed put him in contact with Harris, and Harris told Archer that, if Phlox was successful, the Klingon Empire would stabilize, an outcome that would be quite favorable for Starfleet. Archer remained suspicious of Harris’ motives. After the plague was cured, Harris contacted Reed again, but Reed rebuffed him, saying that he only answered to one commanding officer: Jonathan Archer.
In 2155, Harris agreed to provide intelligence on the Earth-based Human terrorist group Terra Prime to the Enterprise crew, when it was discovered that Terra Prime was attempting to disrupt the creation of the Coalition of Planets and to drive all non-Humans out of the Sol system. Harris implied to Reed that this information would come at a price to be exacted at a later time.
24th century

In 2374, Section 31 attempted to recruit the chief medical officer of space station Deep Space 9, Doctor Julian Bashir, after putting him through psychological testing on the holodeck of a ship to which he had been abducted. Subjecting Bashir to an elaborate deception designed to test his loyalty to the Federation, Section 31 operative Luther Sloan presented himself to Bashir as the Deputy Director of Starfleet Internal Affairs, and placed Bashir in a scenario wherein it appeared that he had defected to the Dominion. Eventually, Sloan became convinced of Bashir’s loyalty and, citing his genetically engineered background and fascination with spy stories, offered him a position within Section 31.
Bashir, appalled at the thought of an organization that was not accountable to anyone and regularly violated the very principles and core values upon which the Federation had been founded, declined Sloan’s offer, although Section 31 continued to regard him as a potential asset. After the agency returned him to Deep Space 9, Bashir alerted the station’s senior staff – including his commanding officer, Captain Benjamin Sisko, and Bajoran Militia officers Major Kira Nerys and Constable Odo – of Section 31’s existence and its attempt to recruit him. Sisko advised Bashir to accept Section 31’s offer to join them, should they ask again, so that Bashir could spy on the organization for Sisko.
In mid-2375, Sloan resurfaced and assigned Bashir to diagnose the health of Koval, Chairman of the Tal Shiar, during an upcoming conference on Romulus.
In the course of his efforts to expose Section 31, Bashir discovered that he had actually been manipulated by Sloan into convincing Romulan Senator Kimara Cretak to access Koval’s personal database, on suspicions that Section 31 planned to assassinate Koval. This gave Koval sufficient evidence to have Cretak arrested and charged with treason, which assured his own seat on the powerful Continuing Committee. Bashir learned that Koval was an agent of Section 31 after discovering Starfleet Admiral William Ross’ complicity in the scheme.
It seemed Section 31 had been planning for what it regarded as a likely war with the Romulan Star Empire following the Dominion War. The agency projected that the Dominion was likely to end up confined to the Gamma Quadrant with the Cardassian Union occupied and left a shambles, and the Klingon Empire left to spend at least ten years rebuilding from the damage left by the Klingon-Cardassian War, the Federation-Klingon War of 2372 to 2373, and the Dominion War itself. Section 31 regarded Cretak as a potential threat to the Federation in the post-war Alpha Quadrant, as her primary loyalties were to the Star Empire’s interests, while Koval could be counted on to influence Romulus in the Federation’s favor.

Admiral Ross attempted to defend his actions to Bashir by stating that the high cost of the war justified the extreme measures being taken, but Bashir refused to concede that the ends justified the means. Ross responded by dismissing Bashir from his office and forbidding him from repeating and otherwise acknowledging their conversation.
