(CNN) -- When a racist image of first lady Michelle Obama surfaced from the ugliest corners of the Internet last week to top Google's image search results, the episode shined a spotlight on the mysterious workings of search engines.

Google placed an ad near the image, apologizing for its offensive nature. But the company resisted calls to scrub the image from its database, saying its role as a neutral tool for searching the Web means having to live with the results, whether it likes them or not.

Google handled almost two-thirds of all Internet searches in the United States in October, according to comScore, making the company the dominant player in the field. Like other search engines, Google relies on a complicated and largely secretive algorithm to decide which Web pages should pop up first based on a user's search terms.

The popularity of a Web site, the number of times a certain page has been viewed, the number of people who have linked to a page from their own pages -- all weigh heavily in the automated decision-making process triggered each time a user clicks "search."

"They [Google] have these 200 different factors that they analyze," said Danny Sullivan, who writes about online search issues at his site, Search Engine Land. "They put them all together and kind of cut it loose and see what it comes up with. It can surprise them as well."

In the case of the crudely doctored Obama image, which replaced her face with that of an ape, Google eventually removed the page on which it first appeared -- but, according to Google, because the page potentially contained malicious software that could harm the computer of anyone who visited it.

As of Tuesday, the image did not appear within the first several hundred results for a Google Images search for "Michelle Obama," although it remained the first result produced by an image search for the words "Michelle Obama ape."

"When the image was coming up on the term 'Michelle Obama,' it was coming up that way against an innocuous query," Rubin said. "If the term you're using is 'Michelle Obama ape,' one could argue that's a relevant result, however offensive it may be."

Sullivan believes Google may have tweaked its search algorithm after finding a bug in its system that caused the Obama image to climb on its results pages.

"When it doesn't do what they want it to do, they go back and start tweaking things," he said. "Long term, you look at how they got there. When you search for Michelle Obama, do you really think that kind of image is one of the most popular things about her on the Internet? I don't think so."

Rubin would not comment on whether any changes were made in the wake of the Michelle Obama incident. But Google and other engines are constantly tinkering with their processes.

Google says it has added an automated feature to prevent "Google bombing," an orchestrated effort by search-engine users to force a specific result.

In 2003, critics of former President George W. Bush gamed the system by repeatedly linking the words "miserable failure" to his official White House biography. Supporters of the Republican president apparently responded, pushing former Democratic President Jimmy Carter's autobiography to No. 2 on the search results for the phrase.

In 2007, comedian and talk-show host Stephen Colbert's fans pushed to link him to the phrase, "greatest living American" -- an effort that worked briefly before Google reversed it.

A result that you're not looking for is not a good search result.--Scott Rubin of Google

"We're always working to improve our algorithm to provide more relevant search results," Rubin said. "We do not make editorial decisions based on our politics or anyone else's."

Sullivan and other observers say the Michelle Obama photo did not appear to be a case of "bombing." Instead, they say, it appears to have slowly crept up Google's image search results until it was noticed, and written about, by bloggers and other media whose attention propelled it to the top.

When negative search results arise on the Web, they recede quicker for some people than for others.

Rhea Drysdale, who handles online image issues for Internet marketing company Outspoken Media, said that the offensive picture of Michelle Obama will fade quickly for a simple reason -- there are so many other images of her on the Internet.

"That's not something that's going to stick with her for long," she said.

As examples, she cited two people who got negative press in 2009: rapper Kanye West and convicted Wall Street swindler Bernie Madoff.

A Google search for Madoff's name delivers page after page of news stories about the multi-billion dollar Ponzi scheme the former investment banker pleaded guilty to earlier this year.

West grabbed headlines, and much criticism online, by barging onstage to interrupt an acceptance speech by country singer Taylor Swift at the MTV Music Video Awards in September.

But search Google for "Kanye West" and the first news account of the incident comes after about half a dozen other items, including West's official Web page, personal blog and Wikipedia entry.

"It's just a matter of news coverage," she said. "Kanye has a blog. Kanye has a MySpace page. He has a record label that writes all these other things about him. If you have any of those other properties that are yours out there, they can fill the search results."

In recent years, a cottage industry has developed among online consultants who help clients manage how they look in Web searches. These hired guns work to push positive news to the top of search results while burying, as best as possible, negative information.

Meanwhile, Google says it will work to try to keep its search results pure.

"A result that you're not looking for is not a good search result," said Rubin, the Google spokesman. "It's not a good search experience."