In this paper, we consider an unreliable production system which has a contractual relationship with a customer for a firm delivery date. Our focus is on the production-related decisions of the manufacturer rather than the nature of the contract itself. We assume that production rate is constant as long as the system is up and running but the randomness in production is due to downtimes as a result of unpredictable failures (breakdowns) and scheduled preventive maintenance activities. The maintenance of the production facility is outsourced to a maintenance contractor. As production output is random, the manufacturer needs to make two important decisions, viz (i) how much time to allow for production taking into account the trade-off between the penalty fee if actual production time turns out to be longer than the deadline and the inventory holding cost if the production time is shorter than the allowed time and (ii) how to design the maintenance outsourcing contract to maximize its own profit while satisfying the contractor’s reservation (minimum) profit requirements. This is a finite horizon optimization problem. A regenerative stochastic process is identified and analysed to develop the cost function over the finite horizon. The optimization problem will be illustrated through numerical examples. Some managerial insights with regard to coordination and some extensions will also be provided.