The standard approach to railway vehicle dynamic analysis includes running the vehicle multibody models in rigid railway tracks. The wheel–rail contact, independently of the rolling contact model used, is either handled online or via lookup tables. This traditional approach disregards the coupling effects between the railway vehicle dynamics and the railway track flexibility. In this work the assumption of rigidity of the railway track is relaxed and a finite element model of the complete track, i.e. rails, pads, sleepers, ballast and infrastructure, is used to represent the track geometry and flexibility. A rail–wheel contact model that evaluates the contact conditions and forces is used online. The dynamics of the railway vehicle is described using a multibody methodology while the track structure is described using a finite element approach. Due to the fact that not only the multibody and the finite element dynamic analysis use different integration algorithms but also because the vehicle and track models are simulated in different, codes a co-simulation procedure is proposed and demonstrated to address the coupled dynamics of the system. This approach allows us to analyze the vehicle dynamics in a flexible track with a general geometry modeled with finite elements, i.e. including curvature, cant, vertical slopes and irregularities, which is another novel contribution. The methodology proposed in this work is demonstrated in an application, in which the railway vehicle–track interaction shows the influence of the vehicle dynamics on the track dynamics and vice versa.