Grant Robertson says being gay was a "factor", but not the only reason, he missed out on being chosen as Labour leader a decade ago.
The former deputy prime minister, who announced his retirement from politics in February, ran for the leadership in 2013 and again in 2014, but lost.
He knew his being gay was an "issue" within the Labour Party and a "factor" in his defeats, he told Q&A host Jack Tame.
"I do think it probably affected [the 2013 bid] . Although whether I would have been able to win that one, even without that, I'm not sure.
"By the time we got to 2014, it was less of an issue the second time around. But it continued to be there."
David Cunliffe was chosen as leader in 2013 and Andrew Little in 2014.
Robertson chose not to run for a third time when the role of Labour leader came up for grabs again in 2017.
Instead, he became deputy prime minister to Jacinda Ardern.
"I was able to be there and support my friend in doing that," he told Q+A.
"That was all enormously fulfilling."
Robertson said he thought briefly about putting his name forward again when Ardern announced she was quitting in 2023, but ultimately decided not to.
"I'd been up close to that job and I knew exactly what it took to do it, and I knew that I didn't have that," he said.
"I thought it would be dishonest to chase a job that I knew I couldn't give the 110, 120 percent that was required."
Robertson is the most senior openly gay politician in New Zealand history.
He said he thought New Zealand had changed a lot in its attitudes to the rainbow community in the decade since his failed leadership bids, but there was still room for improvement.
"I still think there's some distance to go for us to get to a place where people can be who they want to be, live their lives freely and be appreciated for who they are in New Zealand."
Robertson will give his valedictory speech on Wednesday and take up a role as Otago University's vice-chancellor on 1 July.