It seems to derive from a structure like "la victoire/le prix revient au premier qui..." with "au premier" then focused by a c'est cleft:
Ils avaient inventé un jeu ... C'était au premier qui reconnaîtrait l'auteur de ces clichés [que reviendrait la victoire]
Dans la « course à l'espace » entre les États-Unis et l'Union soviétique, c'est au premier qui atteindra la Lune [que reviendra la victoire].
Nous nous sommes précipités hors du bateau et c'était au premier qui trouvait les toilettes [que reviendrait le prix (de se soulager en premier)]
L'après-midi à la sieste, c'était au premier qui me demanderait s'il pouvait dormir avec Calinours [que reviendrait la récompense (de dormir avec)]
The general condition to use that sentence is that the first (au premier), the fastest (au plus rapide), or generally the best at something (à la plus maline, aux plus fourbes, etc.) will gain an advantage, a recompense, or a victory.
The expression "To the victor go the spoils" is quite similar in spirit, I think.
It's hard to find a solid English translation that will fit in all contexts, but a template like this should work:
The [Xst] to [do action] will win / enjoy the prize / get an advantage over the others
The first to recognize those clichés' author would win
The first to reach the moon shall win
The first to find the toilet would enjoy the prize (to relieve themselve first)
The first to ask me to sleep with Calinours would enjoy the prize (to sleep with the plushie)