When a movie is complete, the producer submits a list of final credits to the WGA, and gives a copy of the final script to all writes involved. If any writers disagree with the proposed credits, he can file for arbitration. (Arbitration is automatically triggered if the director or any producers are credited in any writing capacity.)
Different credits have different residual values, meaning a writer can get substantially less or more for the future exploitation of a film (broadcast TV reruns, DVD sales, etc) based on credit. The WGA’s Residuals Survival Guide explains the differences in detail.
In arbitration, WGA members review all drafts of the script, and determine credits based on a formula. The basics for “screenplay” credit, from the WGA’s screen credits policy:
Any writer whose work represents a contribution of more than 33% of a screenplay shall be entitled to screenplay credit, except where the screenplay is an original screenplay. In the case of an original screenplay, any subsequent writer or writing team must contribute 50% to the final screenplay.
You can read more about that and other credits at the WGA’s screen credits policy page.