This paper develops a search theory of labor unions in which the possibility of unionization distorts the behavior of nonunion firms. In the model, unions arise endogenously through a majority election. As unionized workers bargain collectively with the firm, unionization compresses the wage distribution and lowers profits. To prevent unionization, nonunion firms distort the skill composition of their workforce by over-hiring high-skill workers, who vote against the union, and under-hiring low-skill workers, who vote in its favor. Because of decreasing returns to labor, this change in hiring lowers output while reducing the range of wages paid. In the calibrated economy, removing the threat of unionization, by freezing the union status of firms, reduces unemployment and increases output and the variance of wages. Removing, in addition, all unions from the economy leads to a larger increase in wage inequality but does not further affect output and unemployment. These results suggest that the threat that unionization exerts on nonunion firms, more than the fact that some firms are actually unionized, is the main channel through which unions affect output and unemployment in the U.S. economy.