Liberal Democrat home affairs spokesman, Mark Oaten has resigned after newspaper allegations of a gay relationship with a male prostitute.

Mr Oaten, 41, reacted to claims in the News of the World, which said the married father of two had been involved in a relationship with a “rent boy,” in 2004. The paper revealed that he was in a “lengthy” relationship with the man, 23, which included “three-in-a-bed sex.”

News of the World managing editor Stuart Kuttner said Mr Oaten’s announcement came after he was confronted with details of the relationship by reporters. The paper said it had exposed Mr Oaten as a hypocrite who fostered a family-man image and who last year condemned a judge who was sacked for hiring male prostitutes.

Mr Oaten said: “I would like to apologise for errors of judgment in personal behaviour and for the embarrassment caused, firstly to my family but also to my friends, my constituents and my party.”

His resignation comes just days after he pulled out of the Lib Dem leadership race.

A party spokesman said Mr Oaten’s deputy, Alistair Carmichael, would assume temporary responsibility for the home affairs portfolio, which deals with national security and law and order.