This paper presents a game-theoretic model of a liberalized railway market, in which train operation and ownership of infrastructure are vertically separated. We analyze how the regulatory agency will optimally set the charges that operators have to pay to the infrastructure manager for access to the tracks and how these charges change with increased competition in the railway market. Our analysis shows that an increased number of competitors in the freight and/or passenger segment reduces prices per kilometer and increases total output in train kilometers. The regulatory agency reacts to more competition with a reduction in access charges in the corresponding segment. Consumers benefit through lower prices, while the effect on the operators' profits is ambiguous and depends on the degree of competition. We further show that social welfare always increases through more competition in the freight and/or passenger segment. Finally, social welfare is higher under two-part tariffs than under one-part tariffs if raising public funds is costly to society.