Lewis Vaughan gave the Championship side the lead after 13 minutes with a sublime free-kick before Jack Fitzwater levelled for the top-flight hosts in the 70th minute.
Substitute Matej Poplatnik secured the victory in the 109th minute after connecting with Nicky Devlin's cut-back.
Martindale said: "The goal was extremely poor from our point of view. They got a wee kick out of that and there was a ten or 15-minute spell where we struggled to get to grips with them.
"We then started to get to grips with the game. We got behind them and started to dominate.
"Once we equalised I was confident we'd go on and win because we were moving them about and dominating the ball.
"I thought we were good value for it today and deserved the win."
McGlynn: Loads of positives
Rovers sit second in the Championship and manager John McGlynn hopes the performance against Livingston who have finished in the top half of the Premiership, can inspire the players when they return to league action.
He said: "Maybe just all the games that we've had recently caught up with one or two of us whereas Livingston were fresh. But there are loads of positives to take.
"Livingston are fifth in the league, we've come to their patch and over 90 minutes it's one each.
"Last time they played here it was one-one with Hibs, it speaks volumes for our players.
"We've got five league games to go, we're sitting in second and we want to consolidate that position."