We present a bilevel model for transmission expansion planning within a market environment, where producers and consumers trade freely electric energy through a pool. The target of the transmission planner, modeled through the upper-level problem, is to minimize network investment cost while facilitating energy trading. This upper-level problem is constrained by a collection of lower-level market clearing problems representing pool trading, and whose individual objective functions correspond to social welfare. Using the duality theory the proposed bilevel model is recast as a mixed-integer linear programming problem, which is solvable using branch-and-cut solvers. Detailed results from an illustrative example and a case study are presented and discussed. Finally, some relevant conclusions are drawn.