The terrible fact is - your dog died because you made the decision that caused his death.
No matter how much you rationalise that - his demise is because you took action, and that is what is so hard to bear.
But, as others have confirmed, you most certainly did the right thing for him. You had the power to end his suffering, even though it commenced a time of suffering for you, so you had both aspects to deal with.
The strongest deepest love we can give our pets is to let them go when the time has come. When prolonging the inevitable is so that your loss does not have to start, but it means that his suffering has to continue. That is the tipping point, and that is when your love is at its strongest.
And if he could talk, he would thank you for doing the best for him, however painful it is for you, and for doing it because you love him too much to let him hurt any more.
So when the tide of grief ebbs a little, you can think back to what you did, and know it was right, and it was the best thing, and you loved him as much when you let him out of your life, as you did when you let him in.
In fact, because of all the joy you shared, you loved him a little bit more, and that carried you through, and will sustain your memories.