We present a robust dynamic programming approach to the general portfolio selection problem in the presence of transaction costs and trading limits. We formulate the problem as a dynamic infinite game against nature and obtain the corresponding Bellman-Isaacs equation. Under several additional assumptions, we get an alternative form of the equation, which is more feasible for a numerical solution. The framework covers a wide range of control problems, such as the estimation of the portfolio liquidation value, or portfolio selection in an adverse market. The results can be used in the presence of model errors, non-linear transaction costs and a price impact.