The Rajasthan Royals secured second place in the Indian Premier League standings with a dramatic win against the Chennai Super Kings.