Both duly arrived when Raith’s Gordon Smith was brought down in the box by the otherwise excellent Grant Adam.
Adam, the Cowdenbeath keeper, was red-carded and Greig Spence smashed his penalty high into the net to complete his hat-trick and win the match with its last kick.
Spence had started the scoring within two minutes, finishing at the second attempt after being released by a simple long ball. Jordan Morton fired the home side back on level terms six minutes later but Raith were back in front when Adam failed to deal with a long throw-in and Joe Cardle pounced.
The goal of the game arrived just before the half, Kenny Adamson rifling the ball into the far corner on the half-volley after a Kane Hemmings knockdown.
Hemmings turned provider again to give Cowdenbeath the lead, sprinting down the left before squaring for Greg Stewart to finish.
Raith looked have run out of ideas when Adamson was ruled to have tripped Jason Thomson and Spence netted the first of his two penalties.