However you get the key or get Borkul to unlock the gate, head on through and you’ll find Madanach in a remarkably comfortable chamber at the end of the tunnel. Here, things diverge- you can choose to get rid of Madanach and clear your name that way, or you can choose to talk to the King in Rags and work with him to secure your escape. Keep in mind that in siding with Madanach you’d be siding with the Forsworn, who, while supposedly the rightful rulers of the Reach, are rather unsavory, worship the Daedra, and really don’t agree with each other on much of anything but killing off Nords. At the same time, siding against him means supporting the Silver-Blood family, who are arrogant and smarmy as a whole, and who think nothing of working the poor as well as prisoners to death in their mines- but do support the Stormcloaks and run much of the city of Markarth, so there is that incentive.
Siding with Madanach is longer and involves more steps, so I’ll cover that first. Keep in mind that at any point while you are dealing with Madanach, you can turn on him and kill him- in fact, if you kill any of the other Forsworn in the mine before leaving it, you’ll automatically be switched over to the Nord side and the quest goal will become ‘Kill Madanach’.
Madanach is a talkative old man, and he’s inclined to a long conversation with you, trying to convince you of the vileness of Nords as a whole and pointing out that regardless of whether or not you make it out of here, you’re going to be considered a known murderer and felon in the Reach. Keep in mind as he talks that any outright disagreement is basically going to be setting yourself against him and force you into a fight with the man, switching your questline over to the Nord side of things.
In order to get you to see the Nords as he does, Madanach will tell you to seek out Braig, who has been here less time than only the King in Rags himself, and find out his story of why he wound up in the mine. You can talk to Madanach a bit more as well, and find out about the Forsworn- who have been forbidden from worshipping the Daedra since the Nords conquered the Reach, and whose rebellion was harshly put down.
When you talk to Braig, he will first ask about you- giving him favorable answers gets some sympathy, and answers that are evasive or make you seem unlikely to have been oppressed or looked poorly on will be largely ignored. The story of the man, though, is that he once spoke to Madanach- he didn’t take part in any of the Forsworn activities or anything of that sort- and as a result he was sentenced to death. His daughter, who was eight at the time, pleaded that her father be allowed to live, offering herself instead- and so was beheaded. Then Braig was thrown into the mine anyways. The man wants no sympathy, and doesn’t consider what the Forsworn do as a group to be just, he simply is angry.