This, according to Apple, was how the App Store was supposed to work.

On some days, you would have had to scroll through as many as 14 Apple apps before finding one made by a different publisher.

Then more from Apple, all unrelated to podcasting.

The next result would have been Apple’s Compass app.

The first result (after an ad) would have been an app made by Apple: Apple Podcasts.

If you opened the App Store on an iPhone in May 2018 and typed “podcast” in the search box, you would have seen something like this.

Top spots in App Store search results are some of the most fought over real estate in the online economy. The store generated more than $50 billion in sales last year, and the company said two-thirds of app downloads started with a search.

But as Apple has become one of the largest competitors on a platform that it controls, suspicions that the company has been tipping the scales in its own favor are at the heart of antitrust complaints in the United States, Europe and Russia.

Apple’s apps have ranked first recently for at least 700 search terms in the store, according to a New York Times analysis of six years of search results compiled by Sensor Tower, an app analytics firm. Some searches produced as many as 14 Apple apps before showing results from rivals, the analysis showed. (Though competitors could pay Apple to place ads above the Apple results.)

Presented with the results of the analysis, two senior Apple executives acknowledged in a recent interview that, for more than a year, the top results of many common searches in the iPhone App Store were packed with the company’s own apps. That was the case even when the Apple apps were less relevant and less popular than ones from its competitors. The executives said the company had since adjusted the algorithm so that fewer of its own apps appeared at the top of search results.

The Times’s analysis of App Store data — which included rankings of more than 1,800 specific apps across 13 keywords since 2013 — illustrated the influence as well as the opacity of the algorithms that underpin tech companies’ platforms.

Those algorithms can help decide which apps are installed, which articles are read and which products are bought. But Apple and other tech giants like Facebook and Google will not explain in detail how such algorithms work — even when they blame the algorithm for problems.

Philip Schiller, Apple’s senior vice president who oversees the App Store, and Eddy Cue, the senior vice president who oversees many of the Apple apps that benefited from the results, said there was nothing underhanded about the algorithm the company had built to display search results in the store.

The executives said the company did not manually alter search results to benefit itself. Instead, they said, Apple apps generally rank higher than competitors because of their popularity and because their generic names are often a close match to broad search terms.

“There’s nothing about the way we run search in the App Store that’s designed or intended to drive Apple’s downloads of our own apps,” Mr. Schiller said. “We’ll present results based on what we think the user wants.”

Apple added its apps to the App Store in June 2016. Since then, it has been the top result for many popular search terms, according to the Sensor Tower data. Those Apple apps held on for years while top rivals remained stuck below, sometimes hundreds of spots down the list, the data shows.

Results in #1 5 10 Before Apple Music arrived in the App Store, Spotify was for years the first result in searches for “music.” Shortly after Apple Music was added to the store in June 2016, it took the top spot. By then, Spotify had fallen to fourth place. In Feb. 2018, Apple apps suddenly appeared in the top six results for "music" By the end of 2018, there were eight, some of which were unrelated to music. At this point, Spotify was the 23rd result. Spotify complained to European regulators in March that Apple was abusing its role as the gatekeeper of the App Store. By April, all but two of Apple’s apps disappeared from the top results for “music.” Source: Sensor Tower

An Apple spokeswoman said the company could not verify the data because it did not keep a record of historical search results.

The company is facing the most direct legal challenge in the United States to the clout it has built up through its App Store. In May, the Supreme Court voted 5 to 4 to allow an antitrust class action against Apple to move forward, saying consumers should be allowed to try to prove that the technology giant had used monopoly power to raise the prices of iPhone apps.

When multiple Apple apps packed the search results, such as in searches for “music,” the Apple executives attributed the results to a feature of the App Store search engine that sometimes grouped apps by maker. They tweaked that feature in July so Apple apps would no longer look as if they were receiving special treatment. Many Apple apps dropped as a result.

Still, the executives denied that there had been a problem that needed fixing.

“It’s not corrected,” Mr. Schiller said.

“It’s improved,” said Mr. Cue.

Several consultants who study the App Store algorithm to help companies rank higher said Apple’s consistent success in the marketplace was suspicious. Algorithms are automated systems designed to largely run on their own. But it is humans who decide what algorithms measure. And those decisions can be subjective.

“I find it hard to believe that organically there are certain Apple apps that rank better than higher-reviewed, more downloaded competitors,” said Todd Dunham, chief executive of the ASO Project, which consults app makers on how to rank higher in the results.

Some of the search results found in The Times’s analysis appeared “steered,” said Eric Enge, an App Store consultant for Perficient, a consulting firm. “It’s no question that the app universe is one of the major battlegrounds out there, and there’s just a ton to be gained commercially by dominating,” he said.

The average number of Apple apps at the top of search results by month “music” #1 5 10 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “tv” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “video” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “maps” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 The average number of Apple apps at the top of search results by month “music” #1 5 10 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “tv” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “video” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “maps” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 The average number of Apple apps at the top of search results by month “music” #1 5 10 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “tv” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “video” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “maps” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 The average number of Apple apps at the top of search results by month “music” #1 5 10 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “tv” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “video” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 “maps” #1 5 Apr. ‘18 July ‘18 Oct. ‘18 Jan. ‘19 Apr. ‘19 July ‘19 Source: Sensor Tower

The search algorithm in the App Store was built by a small team of engineers in Cupertino, Calif., some of whom said in a separate interview arranged by Apple that they hadn’t noticed for months that Apple was dominating search results for music and other categories.

Once they did notice, they said, a single engineer decided to change the algorithm.

The engineers said they had to be vague when talking about how their algorithm worked, to avoid revealing too much to fraudsters looking to game it. The algorithm examines 42 different signals, they said, including an app’s relevance to a given search, its ratings, and its popularity based on downloads and user clicks.

Apple introduced the App Store in 2008, and it quickly revolutionized the mobile-phone industry, creating a new marketplace for people to download games, tools for work and social-networking services. More than two million apps are available on the App Store.

Apple’s tight control of its App Store has led to a marketplace that appears to be less susceptible to fraud than the Play Store, the app marketplace on Android smartphones that is run by Google. Google’s Play Store results are partly personalized, so each person might see a different set of results.

Companies like Facebook, Spotify and Yelp have thrived on Apple’s platform, which typically generates more money for app developers than Google’s Play Store.

To get their apps discovered, companies try to push them up the ranks in the App Store’s search results. There is an industry of consultants who charge for their expertise on setting the right title, description and other details to please the App Store algorithm.

But Apple’s algorithm also appears to have been a boon for its own apps.

On Aug. 21, Apple apps ranked first in 735 of roughly 60,000 search terms tracked by Sensor Tower. Most of the tracked searches were obscure, but Apple’s apps ranked first for many of the popular queries. For instance, for most of June and July, Apple apps were the top result for these search terms: books, music, news, magazines, podcasts, video, TV, movies, sports, card, gift, money, credit, debit, fitness, people, friends, time, notes, docs, files, cloud, storage, message, home, store, mail, maps, traffic, stocks and weather.

Algorithm change — 1.2% Share of keywords for which Apple apps have ranked first 1.0 0.8 iOS 12 0.6 iOS 11 0.4 iOS 10 beta released to developers 0.2 2017 2018 2019 1.2% 1.0 Share of keywords for which Apple apps have ranked first 0.8 iOS 12 0.6 iOS 11 iOS 10 beta released to developers 0.4 Algorithm change — 0.2 2017 2018 2019 1.2% 1.0 Share of keywords for which Apple apps have ranked first 0.8 iOS 12 0.6 iOS 11 iOS 10 beta released to developers 0.4 Algorithm change — 0.2 2017 2018 2019 1.2% 1.0 Share of keywords for which Apple apps have ranked first 0.8 iOS 12 0.6 iOS 11 iOS 10 beta released to developers 0.4 Algorithm change — 0.2 2017 2018 2019 Weekly median. The number of keywords surveyed every day ranged from 10,000 to 60,000. | Source: Sensor Tower

The Wall Street Journal also found that Apple apps regularly ranked first for many searches in an analysis of 600 searches over two days in June.

Apple succeeded in some of the App Store’s most hotly contested search results. At least four Apple apps led the results for “TV” from at least June 2018 to last month. Netflix has been stuck mostly in the hundreds.

If you searched for “podcast” in May 2018, you would have had to scroll through as many as 14 Apple apps before finding one made by another publisher.

While the Apple Podcasts app has held the No. 1 spot for “podcast” searches since June 2016, other popular podcast apps have struggled in the rankings. A competitor named Stitcher, for instance, has been stuck in the hundreds of podcast search results since June 2018.

That has taken a toll on Stitcher’s business. Amy Fitzgibbons, Stitcher’s marketing chief, said people searching “podcast” accounted for the majority of Stitcher’s downloads on Google’s rival Play Store. “In the Apple App Store, ‘podcast’ did not even rank as a source of downloads for us,” she said.

The Times analysis uncovered other surprising examples of Apple apps’ success. On March 25, the company unveiled an Apple-branded credit card that can be used via the Apple Wallet app. The next day, Apple Wallet was the No. 1 result in searches for “money,” “credit” and “debit.” The app had not ranked for those search terms before then.

Mr. Cue and other Apple executives speculated that the team marketing the Apple Wallet app had added “money,” “credit” and “debit” to the underlying description of the app, causing it to appear for those search results.

Then people searched those terms, found the Apple Wallet app and clicked on it, telling the algorithm that it should be the first result.

“We can just tell you that we’ve not done anything to drive that — that is, other than launching a great wallet, an Apple Card and marketing the heck out of it,” Mr. Schiller said.

When search results were flooded with Apple apps, Apple executives said, the algorithm concluded that people were looking for a specific Apple app and decided to surface other apps by the same developer.

That wasn’t always to Apple’s benefit. For instance, they said, searching “office” returns a series of Microsoft apps because the algorithm recognizes they are looking for Microsoft Office tools.

Apple engineers said the algorithm believed people searching “music” wanted just Apple Music because users clicked on the Apple Music app so frequently. Apple Music had a distinct advantage over other apps: It comes preinstalled on iPhones. Apple said some people used the search engine to find apps that were already on their phones.

When people search “music,” the App Store reminds them that they already have Apple Music installed. Many people then click on the app, the engineers said, adding to its popularity in the eyes of the algorithm.

Over the past several months, Apple engineers said, they began noticing how the algorithm was packing results with Apple apps. First, they stopped the algorithm from doing that for certain searches. In July, they turned it off for all Apple apps.

On July 12, many Apple apps dropped sharply in the rankings of popular searches. The top results for “TV” went from four Apple apps to two. “Video” and “maps” changed from three top Apple apps to one. And Apple Wallet dropped from the No. 1 spot for “money” and “credit.”

Mr. Schiller and Mr. Cue said the algorithm had been working properly. They simply decided to handicap themselves to help other developers.

“We make mistakes all the time,” Mr. Cue said.

“We’re happy to admit when we do,” Mr. Schiller said. “This wasn’t a mistake.”