Stewart Hosie said he wanted to “apologise for any hurt and upset” he has caused and will step back from the role to concentrate on his constituency, responsibilities at Westminster and his health.
The MP is alleged to have had an affair with Westminster journalist Serena Cowdy, who was previously said to have been involved with Angus MacNeil, who represents Na h-Eileanan an Iar in Parliament.
Mr Hosie (Dundee East) said the “intense scrutiny” of his private life had been “very difficult” to deal with.
In a letter to Nicola Sturgeon, he wrote: “I am writing to you firstly to apologise for any hurt and upset I have caused to friends, family and colleagues. That was never my intention.
“I am also writing to tell you of my intention not to seek re-election as deputy leader of the SNP at this year’s annual conference, giving ample time for the party to choose a successor.
“As you know I have been admitted to hospital on three occasions in the past few years with very high blood pressure. In that regard, the stress of the intense scrutiny of my private life has been very difficult.
“I intend to concentrate on my constituents, my responsibilities at Westminster, and most importantly, my health.”
Ms Sturgeon, a close friend of Mr Hosie’s wife Shona Robison, who is Cabinet Secretary for Health, Wellbeing and Sport in the Scottish Government, said she wished him well.
The First Minister wrote: “During your tenure in office, amongst your many other duties, you have authored two successful election manifestos - providing the policy platform for our victories in both the 2015 general election and the 2016 Scottish Parliament election. These are achievements you should be very proud of.
“As you step down as deputy leader, I know you will continue to make a valuable contribution to the party in many ways and, in particular, through your work in your constituency and as part of the Westminster group.”
Shadow Scottish secretary Ian Murray MP said: “Stewart Hosie has made the right decision to resign, but this incident exposes something more significant about the SNP at Westminster.
“Instead of attacking each other, SNP MPs should be focused on delivering for their constituents.
“Last year the SNP told us their MPs would be stronger for Scotland, but just 12 months on many have been a source of real embarrassment.
“This incident hasn’t just seen them let down their party, but they are letting down the people of Scotland who have voted for them and expect much better behaviour.”