This paper presents an embedded beam formulation for discretization independent finite element (FE) analyses of interactions between pile foundations or rock anchors and the surrounding soil in geotechnical and tunneling engineering. Piles are represented by means of finite beam elements embedded within FEs for the soil represented by 3D solid elements. The proposed formulation allows consideration of piles and pile groups with arbitrary orientation independently from the FE discretization of the surrounding soil. The interface behavior between piles and the surrounding soil is represented numerically by means of a contact formulation considering skin friction as well as pile tip resistance. The pile–soil interaction along the pile skin is considered by means of a 3D frictional point-to-point contact formulation using the integration points of the beam elements and reference points arbitrarily located within the solid elements as control points. The ability of the proposed embedded pile model to represent groups of piles objected to combined axial and shear loading and their interactions with the surrounding soil is demonstrated by selected benchmark examples. The pile model is applied to the numerical simulation of shield driven tunnel construction in the vicinity of an existing building resting upon pile foundation to demonstrate the performance of the proposed model in complex simulation environments. Copyright © 2014 John Wiley & Sons, Ltd.