I received an offer, but they have asked for a reference from my ex-manager who I've worked with in the past 5 years.
The challenge is I did not have a good relationship with my ex-manager. The relationship was the reason I left. The environment in my ex company was also pretty toxic so I would ideally not want to provide reference of anyone in the senior leadership.
How do I deal with the situation?
The "spirit" of the reference check is to increase their confidence in hiring you. To satisfy this, you don't need to (and you shouldn't) provide the reference of an ex-manager who you didn't get along with. Instead, identify someone else in a position of authority who you could mention. Some ideas:
Hopefully you have a decent relationship with at least one of these people from your ex-company. If not, you'd have to find someone from the company before that.
Ethan Evans talks about some tactics to improve conflict resolution in his Managing Up course.
What if they insist on someone who has managed me and has to be within the last 5 years. That leaves me with only the option of my ex-manager who I did not have a good relationship with. The other option is to provide current manager's reference who I get along with but I am not sure if that is a good idea either.
I feel like it's totally reasonable to explain that you had a difficult relationship with a former manager. People will accept one not-so-great relationship (but if you say that you hated everyone at a prior job, that can start to hurt you). Phrase it like this:
I learned a ton in my last job, which I'm grateful for. One of the learning was around what kind of management style works best for me, and this mismatch with my ex-manager was difficult and actually one of the reasons I moved on from that job. That experience made me a much more impactful engineer in my current job.
Instead of my ex-manager, I'd love to discuss some other references I could share with you.