The Refinery is the gas extraction building for Terran. When constructed on top of a Vespene Gas Geyser it allows the Terran player to collect Vespene Gas by sending SCVs into it. SCVs collect eight gas at a time and return it to the Command Center until the geyser is depleted, after which they only collect two gas each time. Refineries can only be built on Vespene Gas Geysers and are the only way a Terran player can mine Vespene Gas.
When the main mineral line is under attack, Terran players will sometimes send all their SCVs to the refinery nearby. This tactic is used to a) to send all of them to a fairly safe place, where they won't move from and b) to ensure the SCVs are close-by when mining can be resumed and c) to prevent the SCVs from blocking units coming to defend them.
In rare cases, a Refinery can be built as a means of stealing gas. Since the SCV is vulnerable while building it, it is common to start the construction and then pull away the SCV, forcing the opponent to kill the Refinery-in-construction before taking the gas. In the TvP match-up, the Protoss opponent may similarly attempt to disrupt Terran tech progression by building an Assimilator on the Vespene Gas Geyser at the Terran main and/or natural base; this tactic serves to prevent a Refinery from being built on this occupied Geyser.