On MN an affair wipes out everything else which went before it.
You could be living with a violent thug, but as soon as you have an affair people forget how that might have come about.
Nobody on here can know the details of your marriage but you. And an affair isn’t justified on the basis that a marriage is bad. However an affair is often a wake-up call as to the issues that do exist in a marriage.
What you need to consider here is what you really want to happen. You say that your marriage is in a difficult place. Do you want to work on it? It’s possible that an affair can be a wake-up call to two different things. Either that you actually realise how important your DH and your marriage is to you, in which case you need to have a serious discussion as to how you can put things right, or it is a realisation that in fact the marriage is over and you want out.
I have been where you are. Not with a friend or any kind of agreement that it would only be a one-off, but I’ve been in the position of being in a difficult marriage and then ending up having an ONS with someone else. And for me that was the wake-up call that made me realise I was in fact in an emotionally abusive relationship. I went home and told my DH and then told him that I wanted out. I let him be the wronged party. I held my hands up to adultery so he could get a quick divorce.
Sleeping with someone else is by far one of the most regretful things I have ever done, but it can be hard to see in black and white when you’re on the inside of a situation.
Before we split my ex did such things as switch off the boiler so I couldn’t have heating or hot water while he was out. Ridiculed me for the clothes I wore, the way I ate, took naked pictures of me while I was asleep. There’s more but I could be here all day, and eight years on I am still affected by some of the things he did which back then I seemed to fail to spot.
Two wrongs most definitely don’t make a right, but neither is the world that black and white.
But you need to start by thinking, seriously thinking about what this really means to you, and then take it from there.