The archbishop of Canterbury has said his stance against gay marriage could be seen as "wicked". Justin Welby said he stood by his decision to vote against same-sex marriage legislation, but said that could be seen by some as akin to "racism and other forms of gross and atrocious injustice".

Speaking at the opening on Wednesday of the Evangelical Alliance's new premises in King's Cross, London, he said society had evolving views about sexuality, and many younger people thought opposition to gay marriage was "plain wrong".

The Marriage (Same-Sex Couples) Act received royal assent in July and gay couples in England and Wales will be able to wed at some point next year. The legislation had a tortuous passage through parliament, with staunch opposition from many Conservative backbenchers and religious groups.

Welby said: "What I voted against was what seemed to me to be the rewriting the nature of marriage in a way that I have to say within the Christian tradition and within scripture and within our understanding is not the right way to deal with the very important issues that were attempted to be dealt with in that bill.

"The bill was clearly, quite rightly, trying to deal with issues of homophobia in our society. As I said at the time in the House of Lords, the church has not been good at dealing with homophobia – it has at times, as God's people, either implicitly or explicitly supported it and we have to be really, really repentant about that because it is utterly and totally wrong.

"But that doesn't mean that redefining marriage is the right way forward. That discussion is continuing and the church is deeply and profoundly divided over the way forward on it. I am absolutely committed not to exclude people who have a different view from me, I am also absolutely committed to listening very carefully to them."

He said he would vote the same way if given the choice again. "But I am continuing to think and listen very carefully as to how in our society today we respond to what is the most rapid cultural change in this area than there has been for a very long time.

"We have seen changes in the idea about sexuality, sexual behaviour. We have to face the fact that the vast majority of people under 35 not only think that what we're saying is incomprehensible but also think that we're plain wrong and wicked and equate it to racism and other forms of gross and atrocious injustice. We have to be real about that.

"I haven't got the answer one way or the other until my mind is clear on this. I'm not going to get into the trenches."

Welby has previously said there has been a "revolution" in attitudes towards homosexuality, particularly among young people, and has said that the Church of England needs to acknowledge the changes in opinions.