Just encountered a bug in Skyrim where, if you come nearby a city guard anywhere around Markarth, they would hunt you and start the dialog in which you can't pay your way out. The problem is that, even if you select to go to jail, you can't go there either and the dialog simply restarts. The only way out of the dialog is to start a fight. There's also a glitch in a glitch so sometimes you can just close the dialog by pressing Tab and guards would continue their way. However, this is not a solution in case you need to pass through a passage guarded by a couple of guards.
Fortunately, there is a solution. Sounds more like a hack but, since it resolves a bug, is not that bad. There might be other solutions with quests that set/reset status but this one was the first one I tried and it worked. The glitch is caused by helping the Forsworn during the prison break, after they get out of the mines. So, here goes the solution for the PC:
1. Travel to Markarth
2. Walk up to a city guard and begin the "You've committed crimes..." dialog
3. Do not select any dialog options
4. Hit the tilde key ( `/~ key above the tab key) to bring up the console
5. Using either the game pad or the mouse position the cursor right in the middle of the guard's head and click on his head. You should now see a hex code in the console. It is important that it is the guard's head - not his body.
6. Type paycrimegold into the console and hit enter
You'll hear the gold "cha ching" sound and the game will teleport you somewhere random in Markarth. Hit tilde again to exit the console and the glitch will now be fixed. You can interact with Markarth as per normal. This is not cheating as the bounty on your head cannot be cleared by normal means and the bounty should have been lifted at the end of the quest so you aren't breaking the game.