Designing the geometry of a ship’s hull to guarantee a correct anchor maneuver is not an easy task. The engineer responsible for the design has to make sure that the anchor does not jam up during the lifting process and the position adopted by the anchor on the hull is acceptable when it is completely stowed. Some years ago, the design process was based on wooden scale models of the hull, anchor and chain links, which are expensive, their building process is time consuming and they do not offer the required precision. As a result of this research, a computational tool to simulate the anchor maneuver of generic ships given by CAD models was developed, and it is proving to be very helpful for the naval engineers. In this work, all the theory developed to simulate anchor maneuvers is thoroughly described, taking into account both the behavior of the anchor and the chain. To consider the contact forces between all the elements involved in the maneuver, a general contact algorithm for rigid bodies of arbitrary shapes and a particular contact algorithm for the chain links have been developed. In addition to the contact problem, aspects like the dynamic formulation of the equations of motion or the static equilibrium position problem are also covered in this work. To test the theory, a simulation of the anchor lifting maneuver of a ship is included as a case study. In spite of the motivation to develop the theory, the algorithms derived in this work are general and usable in any other multibody simulation with contacts, under the scope of validity of the models proposed. To illustrate this, the simulation of a valve rocker arm and cam system is accomplished, too. The computational and contact detection algorithms derived have been implemented in MBSLIM, a library for the dynamic simulation of multibody systems, and MBS model, a library for the contact detection and 3D rendering of multibody systems.