Google AdWords uses a combination of quality/relevancy scoring and a bid-based system known as "cost per click." Potential advertisers are ordered based on how much they're willing to pay per each click on their ad and then further subordered based on the quality of their ad and resulting page.
When signing up for advertising through Google AdWords, advertisers are asked to choose sets of keywords for their ads and are placed in the search results for these keywords based on how relevant their submitted link appears to be to the search. This ad quality rating is further established based on the expected rate of clicks for the ad and the user's experience after clicking through the ad the webpage.
Google AdWords ads are not only limited to the Google search engine but may also show on a number of other Google-owned and -affiliated websites including YouTube and the New York Times website. These are called "placements" in their "Display Network" and can be based on not only the site's built-in search engine but also the content of the site's Web pages, if relevant keywords are detected.
When the Google AdWords engine attempts to place an ad, it gathers up all available advertisements and puts them through an auction-like process in which the highest bidder via the cost-per-click system pays the lowest amount based on competing bids. This is done automatically based on what the advertiser has chosen to pay when registering its ad.