John Swinney has been doing Kate Forbes' finance secretary job while she is on maternity leave
John Swinney said he profoundly disagreed with Ms Forbes despite also having "deep religious faith".
He questioned whether it would be appropriate for someone with her views to be SNP leader.
But he stopped short of calling for Ms Forbes to quit the race to succeed Nicola Sturgeon.
Mr Swinney has been standing in for Ms Forbes as Scotland's finance secretary while she was on maternity leave following the birth of her daughter last year.
Responding to Mr Swinney's remarks, a spokesman for Ms Forbes said: "The prime minister is a Hindu, the mayor of London is a Muslim.
"So many will wonder why the deputy first minister believes a woman holding Christian views should be disqualified from holding high office in Scotland."
A campaign source told the BBC that Ms Forbes intends to "fight on" and that any speculation she is going to pull out of the contest is wrong.
Ms Forbes took time out of the media spotlight on Wednesday as she attempts to reset her campaign following controversy over a series of interviews she gave on Monday and Tuesday.
Several key backers withdrew their support after she made clear she would not have voted for gay marriage if she had been an MSP in 2014.
She also said that she personally considers it "wrong" for children to be born outside marriage because of her faith as a member of the Free Church of Scotland, which opposes abortion and same-sex marriage.
Ms Forbes has said that people should not be excluded from political office because they are a member of a particular faith.
And she said she would "defend to the hilt everybody's right in a pluralistic and tolerant society to live and to love free of harassment and fear".
It is understood Ms Forbes has brought in a media adviser as part of her effort to reshape her campaign.
Speaking to the BBC's Good Morning Scotland programme, Mr Swinney pointed out that several churches - including the Church of Scotland - conduct gay marriages.
He said: "All of the debate that has been aired about Kate Forbes' position for me has got absolutely nothing to do with Kate's faith.
"I'm a man of deep Christian faith but I do not hold the same views as Kate has set out in the course of the last couple of days.
"Kate is perfectly entitled to express her views, but party members are equally entitled to decide if someone who holds those views would be an appropriate individual to be SNP leader and first minister."
Meanwhile, Ms Sturgeon denied that the party was tearing itself apart in the contest to replace her as she visited a BMX centre in Glasgow on Wednesday morning.
Ms Sturgeon has not endorsed any of the three candidates, but said the views of the next first minister matter because people want to see someone who will stand up for them and their rights.
She also said the majority of people in Scotland wanted it to be a socially progressive country.
The SNP's Westminster leader Ian Blackford, who is also a member of the Free Church, said it was important to "defend and celebrate" gay marriage, and joined Mr Swinney is questioning whether someone who holds Ms Forbes' views would be the right person to lead the country.
The church on Skye that Mr Blackford attends criticised him in 2019 for voting to legalise abortion and gay marriage in Northern Ireland, which it said "does not reflect the beliefs or the teaching of the church".
But former SNP MSP Dave Thompson - who held the Skye, Lochaber and Badenoch seat before Ms Forbes - said the country was "going down a very dangerous road" if people with particular views could not hold political office.
Mr Thompson, the convenor of Christians for Independence, added: "Angela Merkel voted against gay marriage even though it was passed by her parliament. The principle is exactly the same.
"Kate has said she would not impose her views on others. I think she can win and I think she will."
The Free Church of Scotland said it was composed of people "from all political persuasions, some of whom will not share Kate's politics, particularly over an independent Scotland".
It said it was concerned at the level of "anti-Christian intolerance which has been displayed on social media, and by some political and media commentators".
A spokesperson said: "It is lamentable that Kate's honest adherence to simple traditional values would, for some, disqualify her from contributing to the public good of Scotland.
"Kate Forbes is standing on the basis of her policies - the fact that she is being criticised for her Christian convictions shows a level of bigotry that has no place in a pluralistic and diverse society."
Ms Forbes' rivals to replace Ms Sturgeon are Health Secretary Humza Yousaf and the former community safety minister, Ash Regan, who has announced plans to formally launch her campaign on Friday.
Both Mr Yousaf and Ms Regan have said they back gay marriage - although Mr Yousaf was absent when the final vote on legalising it was held in 2014 despite supporting it at an earlier stage.
Ms Regan has called for an end to "mudslinging" in the contest, adding: "We've all got to remember that we're all going to be working together at the end of this."
Mr Swinney, a former leader of the SNP who had been tipped by some to stand again, has not yet openly backed any of the three candidates in the contest despite speculation he might endorse Mr Yousaf.
He said he would wait until nominations close on Friday before considering whether to "say any more" in the contest.
He also said there was no prospect of him entering the leadership race before Friday's deadline as the party needed some "fresh perspective".
Some in the SNP have been encouraging the social security minister, Ben Macpherson, to make a late entry into the contest but he has decided against doing so.
Nominations close on Friday and the winner will be announced on Monday 27 March.
Scottish Conservative chairman Craig Hoy said the "increasingly bitter" leadership race had exposed "deep divisions within the SNP on everything that isn't about breaking up the UK".
And he said Mr Swinney had "seriously undermined Kate Forbes, his former protege, by questioning her appropriateness to be SNP leader".