Method for the surface treatment of a dental implant or a prosthetic component made out of titanium or a titanium alloy, which enables an outer surface of the implant or the prosthetic component to be obtained with a notable capacity to prevent bacterial adhesion and offer a better aesthetic finish. This method comprises the steps of providing an outer surface of the implant or the prosthetic component with a surface roughness, and applying an anodizing treatment on the implant or the prosthetic component, smoothing the roughness and generating nanopores on this outer surface of the implant or the prosthetic component. The invention also relates to a dental implant or a prosthetic component made out of titanium or a titanium alloy, which comprises an outer surface that is rough and has nanopores.