What should you do when you know you should breakup because of significant differences ideologically, but you still both love each other deeply?

My boyfriend and I love each other very much. We are best friends and are super close. However, we have significant ideological issues and when we started discussing getting married, we became worried about our future together because he’s more religious and I am not at all and we have very different core beliefs that cause a lot of friction. We decided to breakup today but we are both hurting a lot because we love each other and we are just breaking up because we know we can’t get married, but it hurts. I am feeling a lot of pain and am wondering what other people have done in these situations.