EBay Inc. is talking to both Yahoo Inc. and Microsoft Corp. to determine whether one of them might be a worthy ally against a common threat: Google Inc.

After years of working closely with the search giant, eBay last year became alarmed as Google started assaulting its turf in multiple ways. In one case, Google launched a classified-advertising service that competes directly with eBay's online auctions and other listings.

The two-track discussions began in earnest last autumn, people familiar with the talks say. They could result in some kind of alliance in which eBay, of San Jose, Calif., would increase ad spending with its chosen partner and provide access to the wealth of data it has collected about its consumers. The two sides could also more tightly integrate technical aspects of their systems to better cross-promote their businesses.

It's not clear how much money would be involved or whether the parties have considered a more complex financial transaction, such as one side taking an equity stake in the other.

But choices are seldom clear-cut in today's Web business. Upon hearing of eBay's talks, Google, Mountain View, Calif., offered an olive branch, in the form of a series of proposals designed to tighten the relationship between the two companies. The superiority of Google's search technology makes it a better place to advertise, say people familiar with eBay's thinking.

Today, eBay is in a curious position -- negotiating alliances to wean itself from Google while discussing deeper ties with it. Tech companies have long had to walk such a delicate line between cooperation and competition. But these days, Google's clout has magnified the problem.

EBay has "known for some time that Google poses tremendous opportunity in the short term but is perhaps their biggest threat in the long term," says Jeff Lanctot, general manager of Avenue A/Razorfish, an online-advertising agency.

EBay, Yahoo, Google and Microsoft are clear leaders in the tech world and yet their competitive landscape is still profoundly uncertain. In particular, the rapid growth of online advertising has injected new competition into the Web, forcing the foursome to challenge each other in ways they hadn't in the past.

So dizzying is the array of potential options that eBay executives have drawn up a chart mapping its three main businesses -- an auction marketplace, the PayPal online-payment service and Skype, an Internet phone service -- along with potential partners for each. The decision eBay makes will go a long way toward determining what kinds of businesses it will be in. Executives from the companies involved think these talks could herald mergers or acquisitions that would reshape consumer commerce on the Web.

Each company is offering eBay a somewhat different package. At their core, though, the talks are about advertising. Whoever wins eBay will probably gain the right to display their clients' ads on eBay's millions of auction pages. Google, Yahoo and Microsoft all have systems in place that syndicate advertising to third-party Web sites, with all parties sharing the revenue. EBay doesn't currently run such ads. The winner would also get ad dollars from eBay, one of the Web's biggest advertisers.

People involved in the talks say that any, or all, of the discussions may fall through and that no date has been set for a decision. EBay already does business with all three companies and will likely maintain ties with all.

EBay spokesman Chris Donlay declines to comment on any talks and plays down the company's rivalry with Google. "Given how fast the Internet changes, it's no surprise that the line between competition and cooperation is sometimes blurry," he says. Spokespeople for Yahoo, Google and Microsoft also decline to comment.

EBay's conundrum stems from its deep dependence on Google, one that started when eBay became one of the first customers of Google's search-based advertising system. When Internet users search on Google, the service brings up text ads related to those words on the results page. In 2001, eBay paid Google to post ads for its auctions pegged to thousands of search words. Search for "antiques," say, and Google would post an eBay ad with text such as: "Whatever you're looking for, you can get it on eBay."

EBay's spending on Google soared, dwarfing spending on similar services such as Yahoo's Overture and Microsoft's MSN. John Aiken, managing director at Majestic Research, an independent equity-research firm, estimates that eBay spends about twice as much on Google ads as other individual search engines, and that Google brings up to three times as much traffic to eBay as other search engines. EBay won't give details about its ad spending.

Few at eBay initially saw reason to fear Google, say people at the company, in part because of a 2003 study it commissioned from McKinsey & Co. McKinsey concluded that Google wouldn't use its search capabilities to break into e-commerce. That made Google a manageable threat, say people familiar with the study. EBay's dependence on Google increased as it shifted ad dollars to online ads from traditional media throughout 2004.

But 2005 brought worrying signs that Google had the potential to become an entry point to the Internet for online shoppers, challenging eBay. Google, as part of a broader hiring spree, began recruiting eBay engineers and business staff. Senior eBay executives feared Google was staffing up for a move into e-commerce, say people familiar with the matter. In June, news broke that Google was developing a system for online merchants to take payments securely. Few details were available, but it sounded like a competitor to PayPal, eBay's own online-payment service.

Then, in October, Google started testing a free online-classified service, Google Base, a product targeted at the heart of eBay's business.

Even before news of Google Base became public, eBay executives met that summer to assess the threat. In a role-playing exercise, they split into two groups: A "green team" pondered eBay's interests; a "red team" tried thinking like Google, say people familiar with the meetings. The greens returned with status-quo scenarios in which eBay and Google continued collaborating, these people say. The reds, in Google's shoes, concluded that Google would move onto eBay's turf.

The conclusion was troubling. EBay was boxed in to its relationship with Google. A big chunk of eBay's approximately $400 million global online-marketing budget goes to Google, say people familiar with the matter.

In September, in Telluride, Colo., at an annual retreat, senior eBay executives discussed how Google might attack eBay, according to people familiar with the meeting. PayPal executives theorized that Google could offer free ad services to companies in return for agreeing to use Google's rival online-payments system.

PayPal President Jeff Jordan, called for eBay to be more aggressive in shoring up its defenses. Google "has catalyzed the Valley" into figuring out ways to oppose it, says Mr. Jordan. Other eBay executives, by contrast, considered Google the best search company and played down the competitive threat.

By mid-Autumn, there was a consensus that eBay needed to consider alliances to wean itself from Google. The logical choices were Yahoo, Sunnyvale Calif., and Microsoft, Redmond, Wash.

Both companies wanted eBay's ad dollars and access to its huge number of users. Yahoo and Microsoft covet information about eBay's shoppers, who are more likely than regular Internet users to buy products online. The data would help the companies finesse the underlying algorithms that guide their search systems.

In early talks, Microsoft wanted eBay to advertise on its embryonic AdCenter, a service currently on trial designed to compete with Google's ad system. But eBay thought the quality of Microsoft's search results lagged behind Google's and worried that Microsoft's site didn't have enough users, say people familiar with the talks. That meant eBay ads there would be less effective.

But by the time of the September Telluride retreat, eBay was feeling the pressure and decided to step up talks with Microsoft. EBay Chief Executive Meg Whitman discussed with her Microsoft counterpart Steve Ballmer ways the companies could work together, says a person familiar with the meeting. Ms. Whitman and Mr. Ballmer decline to comment through their respective spokespeople.

Behind the scenes, Microsoft was negotiating with Time Warner Inc.'s AOL unit a partnership that could increase traffic to Microsoft's site, a deal that Microsoft managers hoped would address part of eBay's concerns. In December, Microsoft's plans took a big hit when Google swept in, investing $1 billion in AOL for a 5% stake.

Days after losing the deal, Microsoft Vice President Yusuf Mehdi wrote a memo to Microsoft's search team. Under the heading "Plan B," the email said Microsoft needed to step up its efforts to make alliances with eBay and other e-commerce sites.

That directive helped intensify the talks. Microsoft talked about giving eBay special access to its search results, say people familiar with the matter. That would allow eBay users who didn't find what they were looking for on the auction site to immediately see information gleaned from Microsoft's search. The two companies also discussed how to make PayPal a more integral part of Microsoft's software and Web portal, say people familiar with the talks.

EBay, however, was also exploring other options. After the Telluride retreat, it stepped up talks with Yahoo. The pair had held inconclusive talks earlier in the year.

Yahoo itself had been rattled by Google Base, the classified-ad system, which seemed aimed at several Yahoo businesses from personal ads to shopping listings. "Both companies realized they needed each other," says a person familiar with the talks.