A senior member of David Cameron's shadow cabinet made his name as a student leader on the back of an openly homophobic stance at the University of Glasgow, the Sunday Herald can reveal.

Liam Fox, the shadow defence secretary, quit his post on Glasgow's student council in the 1980s over his opposition to a gay society being admitted to one of the university's unions.

He explained at the time saying he did "not want the gays flaunting it in front of me, which is what they would do".

The comments are an embarrassment for Cameron, whose "compassionate conservatism" includes support for gay rights.

Fox, a Scot who stood against Cameron for the Tory leadership in 2005, is a foreign policy hawk and social conservative on the right of the Conservative party.

He studied medicine at Glasgow university, where he also cut his teeth as a member of the Tory club.

His profile rose in 1982 when a row broke out over whether the student gay society should be admitted to the Glasgow University Union (GUU).

The society's application was turned down in terms that can only be described as homophobic.

The GUU president at the time, Vince Gallagher, said: "We just do not want poofs in our union. I wish they would just bugger off and give us peace."

The stand-off was reported in national newspapers and led to other universities cutting their ties with the GUU.

The university's Student Representatives' Council (SRC), the elected body for undergraduates, passed a motion condemning the GUU's decision and the "bigoted explanations" given for it.

But the motion led to one SRC member, Liam Fox, resigning in protest.

He was reported in the student newspaper, the Glasgow University Guardian, as saying the SRC's position was "unacceptable", and he explained his decision to quit: "I think it is obvious that the GUU speaks for the vast majority of students on campus. The SRC is totally unrepresentative and speaks only for minorities. I feel they are becoming a tool for the QM Queen Margaret Union."

Fox was reported as saying: "I'm actually quite liberal when it comes to sexual matters. I just don't want the gays flaunting it in front of me, which is what they would do."

The GUU's position led to the Edinburgh University Students' Association ending its "reciprocal agreement" with the union, and resulted in universities across Scotland condemning Glasgow.

Jack McConnell, the then president of Stirling's students, was quoted saying: "I find it appalling that in 1982 a group of students should act in this way. The GUU must be ostracised like it was over its refusal to admit women."

Fox's parliamentary career has seen him develop a reputation for being unsympathetic to gay rights. He voted against reducing the homosexual age of consent to 16 and was reportedly part of shadow cabinet's "gang of three" who, when Iain Duncan Smith was Conservative leader, imposed the whip on Tory MPs to oppose gay adoption.

In an interview in 2005, Fox was asked about rumours of a gay past: "I know that some people use smears and I have heard them for years. They'd say, Why are you not married? You must be a playboy or a wild man or gay,' or whatever. Well, I'm getting married in December and I'm perfectly happy with my private life."

Peter Tatchell, a gay rights activist, said: "This homophobic stance, while a student, seems to be part of a pattern of anti-gay prejudice that has continued right up until recent years.

"I am ready to forgive him and move on, but only if he makes a clear public statement expressing regret for his past homophobia."

Fox yesterday said: "Fortunately most of us have progressed from the days when we were students more than a quarter of a century ago."