We study a dynamic general equilibrium model in which firms choose their investment level and their capital structure, trading off the tax advantages of debt against the risk of costly default. The costs of bankruptcy are endogenously determined, as bankrupt firms are forced to liquidate their assets, resulting in a fire sale if the market is illiquid. When the corporate income tax rate is positive, firms have a unique optimal capital structure. In equilibrium firms default with positive probability and their assets are liquidated at fire-sale prices. The equilibrium not only features underinvestment but is also constrained inefficient. In particular there is too little debt and too little default.Keywords: Debt, equity, capital structure, default, market liquidity, constrained inefficiency, incomplete markets All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means without the prior permission in writing of the publisher nor be issued to the public or circulated in any form other than that in which it is published.Requests for permission to reproduce any article or part of the Working Paper should be sent to the editor at the above address. The equilibrium not only features underinvestment but is also constrained inefficient. In particular there is too little debt and too little default.JEL Nos: D5, D6, G32, G33