What determines whether a Search ad shows in the results for a query, and in what position?

Bids, which is how much marketers will pay for a click.

Asset impact, which includes sitelinks and image assets.

Ad Rank, which is based on a variety of factors to show useful ads.

Ad quality, which is based on ad and website relevance.