An implant comprising a main body made of magnesium or a biocorrodible magnesium alloy and a corrosion-inhibiting passivation layer covering the main body. The passivation layer is characterized in that it contains a 3-polyhydroxyalkanoate and the 3-polyhydroxyalkanoate is a homomer or copolymer with a polymer segment of formula (1):where R=propyl, butyl, pentyl or hexyl.