Andrew Richards, 26, was the first person to be sentenced for the offence following implementation of the Criminal Justice Act last year.
Judge Richard Lowry QC said at the Old Bailey that the new law gave him greater sentencing powers to combat the growing problem of male rape.
The charge of buggery which was used previously in such cases carries a maximum sentence of 10 years. Rape or attempted rape carries a maximum sentence of life.
Richards, who has a record of sex crimes, was found guilty last month of attacking an 18-year-old man. Sentence was adjourned until yesterday for reports.
These revealed he suffered from a psychopathic personality disorder which was compounded by his use of drugs, glue and alcohol. A psychiatrist said he had a "seething mass of resentment" to anyone in authority.
His counsel, Mario Addezio, said Richards "does not care if he lives or dies".
The judge described Richards, of Neath, West Glamorgan, as "shrewd with a degree of cunning". He told him: "You are a danger to the public and children of both sexes. My first concern must be to protect the public."Reuse content