Original: In two-parter "The Best of Both Worlds" Riker takes command of the Enterprise assuming the rank of Captain through a field promotion and orchestrates Picard's rescue.
Simplified: On part 1-2 on the episode "The Best of Both Worlds" Riker takes command on the Enterprise and orders Jean-Luc Picard rescued.