We analyse an optimal trade execution problem in a financial market with stochastic liquidity. To this end, we set up a limit order book model in continuous time. Both order book depth and resilience are allowed to evolve randomly in time. We allow trading in both directions and for cadlag semimartingales as execution strategies. We derive a quadratic BSDE that under appropriate assumptions characterises minimal execution costs, and we identify conditions under which an optimal execution strategy exists. We also investigate qualitative aspects of optimal strategies such as e.g. appearance of strategies with infinite variation or existence of block trades, and we discuss connections with the discrete-time formulation of the problem. Our findings are illustrated in several examples.