Medical device (65) for implantation in a hip joint of a patient, wherein the medical device is adapted to be fixated to the pelvic bone (9) of the patient. The medical device comprises an inner (1827) surface, wherein a contacting portion, of the inner surface is spherical and adapted to face the centre of the hip joint when the medical device is implanted. Further it is adapted to receive a caput femur (5) or a prosthetic replacement therefor having a spherical portion. Moreover, either of the medical device (65) and the caput femur (5), or a prosthetic replacement therefor, comprises at least one magnet (822; 823), and the other one of the medical device and the caput femur or a prosthetic replacement therefor, comprises at least one cooperating magnet or magnetic material. Hereby, the spherical portion is restrained in the medical device by means of a magnetic force between the magnet (823; 822) and the cooperating magnet (823; 822) or magnetic material.