The first person to bring a clear and complete invention disclosure to the patent office sits in the 'catbird seat'. The first person to officially establish this invention disclosure is said to have 'priority' and will ultimately be entitled patent rights where more than one person files some later filed duplicative application for patent.
One gains priority in several ways. For example, you may gain a priority date by filing a provisional patent application. A non-provisional application which depends upon an earlier filed provisional application may have as its priority date the date of the provisional provided the provisional application is sufficiently detailed enough to describe the invention. In another example, a foreign filed application may serve to impart a priority to a U.S. application which claims benefit of the earlier filing date. The later filed U.S. application will have an effective date same as the original filing date of the foreign application.
First to File, First Inventor to File, First to Invent
In times past, only the first person to make an invention was entitled a patent. Now, all persons who make an invention are entitled to patent it – provided it is not already patented. If you make an invention and someone else made that same invention 10 years ago but did not patent it, you will still be able to get a patent. Previously, if the earlier inventor could prove with his lab notes for example that he actually made the invention first – you'd lose your rights to the invention.
In countries other than the United States, the first person to file, whether they made the invention or not, gets the patent. In the United States, you still must be a true inventor. In the United States, one cannot see another person's idea and run off to the patent office to get a patent. Seemingly unfair, this is normal practice in most other nations. Those may be referred to as 'First to File' nations. The United States recently switched from a 'First to Invent' to a 'Inventor-to-File.aspx" title="IIP Topic" alt="IIP Topic">First Inventor to File' system.