This study develops a novel agent-based model of the interbank market with endogenous credit risk formation mechanisms. We allow banks to exchange funds through unsecured and secured transactions in order to facilitate the flow of funds to the most profitable investment projects. Our model confirms basic stylized facts on (i) bank balance sheet distributions, (ii) interbank interest rates and (iii) interbank lending volumes, for both the secured and the unsecured market segments. We also find that network structures within the secured market segment are characterized by the presence of dealer banks, while we do not observe similar patterns in the unsecured market. Finally, we illustrate the usefulness of our model for analysing a number of policy scenarios.