FORTUNE — “I’d like to take you on a journey.” A group of 2,500 eBay employees is assembled at the San Jose Civic, a concert venue a few miles from company headquarters. Their boss, CEO John Donahoe, is onstage, asking them to reflect on their work. “Close your eyes,” he urges in a deep baritone. “What is the thing you are most proud of that your team has accomplished this year?”
Donahoe then begins to ruminate on his eight years at eBay (EBAY), five of them as CEO. He’s delivered a variation of this speech to employees in Ireland, Germany, and other eBay locations in the U.S., yet on this December morning Donahoe still sounds raw, almost confessional, as he recounts his moments of self-doubt — such as the night in June 2008, before he was due to appear at a sellers event in Chicago. It was months after he had announced sweeping changes to eBay’s fee structure, and sellers were irate. One went so far as to create a YouTube video comparing Donahoe to a Nazi guard in Schindler’s List. (Seriously.) Donahoe recalls, “I remember sitting in a hotel room that night and thinking, Is this worth it?”
Five years later he has his answer. Under Donahoe’s leadership eBay has undergone a remarkable transformation, shifting from its original (and flailing) mission — online auctions — to a full-service e-commerce operation that helps big retailers such as Home Depot (HD), Macy’s (M), and hundreds of others navigate the complex world of mobile payments, online comparison shopping, and same-day delivery. In other words, eBay is quickly emerging as the shopkeeper’s best answer to Amazon (AMZN), which continues to disrupt the retail world with deep discounts and a dizzying array of new businesses. “Retailers are coming to us and saying, ‘We need to have a technology partner,’ ” says Donahoe.
eBay has long offered merchants valuable e-commerce tools — most notably its wildly successful PayPal payments service. Donahoe has bolstered the company’s wireless offerings with acquisitions such as Zong, a mobile transactions company, and RedLaser, a price-comparison app. In 2011 he orchestrated the purchase of $2.4 billion GSI Commerce, which builds and manages online shopping sites for giant retailers, and late last year the company announced a deal that will allow consumers to use PayPal at any brick-and-mortar location that accepts the Discover (DFS) card. (Imagine a clerk asking, “Cash, credit, debit, or PayPal?”) The moves enable eBay to offer retailers a full suite of commerce services. They’re also fueling growth: Last year eBay posted $14.1 billion in revenue, up 21% from a year earlier. The payments business, mainly PayPal, grew 26%, to $5.6 billion in revenue. eBay Marketplaces, increasingly a showcase for fixed-price items, was up a healthy 11%. Auctions, Donahoe says, “are less than 10% of what we do.”
Investors are responding enthusiastically to the new eBay — the stock is up 70% in just the past year and has outperformed much of the tech sector, including Amazon — and analysts say Donahoe deserves much of the credit for pulling off that rarest of feats in the tech world: a company turnaround. (The most famous tech reversals of fortune – Apple (AAPL) and IBM (IBM) — are the stuff of legend.) “I consider Donahoe’s accomplishments at eBay nothing short of amazing,” says Gil Luria, a Wedbush Securities analyst. “He took an underperforming Silicon Valley giant and transformed it into a high-growth, innovative, mobile-focused technology leader.” Adds venture capitalist and eBay board member Marc Andreessen: “If Steve Jobs or Mark Zuckerberg are the templates for the founder CEO, then I think John has become the template for the professional CEO.”
When Donahoe arrived at eBay in 2005 to run the Marketplaces business, the place was already in decline. “What I found was a company being disrupted around the edges,” says Donahoe, who had spent more than 20 years at Bain & Co. Growth of the auction site, its core business, had dramatically slowed. Shoppers’ habits were changing; eBay wasn’t necessarily their first stop for products — they were turning to Amazon, which had expanded well beyond books, or simply using Google (GOOG) to search for bargains. eBay was also having trouble figuring out what to do with its $2.5 billion acquisition of Skype, completed in 2005. (Customers, it seems, didn’t actually want to video chat about their latest purchases.) By 2009, nearly a year after Donahoe became CEO, shares had dropped from an all-time high of $58 in 2004 to just over $10.
There was a time when eBay was a hip place to shop. When rare collectibles or the latest fads were hard to find, people looked to eBay. According to company folklore, Pierre Omidyar started the company in 1995 to help his wife connect with other Pez-dispenser collectors in Silicon Valley. (Indeed, a glass-encased wall chock-full of Pez dispensers remains in one of the office buildings in San Jose to this day.) But in truth, Omidyar founded eBay to create the “perfect market,” a website with an auction format so that all users had an equal shot at walking away with what they wanted — an Everyman’s web version of Christie’s auction house.
But like so many former dotcom darlings, eBay seemed stuck in its glory days, unable to keep up with the changing dotcom world it had helped create. Even after the tech bubble burst in the early 2000s, the company’s hiring frenzy continued. At one point, former managers say, as a hot property able to draw top talent, eBay recruited hundreds of employees a year. That led to cases in which overqualified candidates swooped into lower-ranking positions. Vice presidents at other companies took product manager jobs at eBay, for instance. “They were happy for about 15 minutes, but then everyone wanted that next job,” recalls a former executive. Employees had become so absurdly self-congratulatory that people clapped at the end of many meetings, even after discussions over declining customer satisfaction and engagement.
“They didn’t seem to see what was going on outside the company in terms of competition,” founder Omidyar says. “They had lost their ability to innovate, to create new things.” Meg Whitman, eBay’s CEO from 1998 to early 2008, presided over its meteoric rise and its decline. Now the CEO of computer giant Hewlett-Packard (HPQ), Whitman acknowledges that the company lost sight of its inventive spirit. “In 20/20 hindsight, making sure we stayed focused on the technology, making sure we were really ready to leapfrog to the next thing on the Internet? Absolutely you could say we could have done that faster,” she tells Fortune.
Perhaps Whitman’s savviest move in her final years at eBay was to recruit Donahoe, whom she knew from her own stint at Bain in the 1980s. She invited him to test the waters by running the Marketplaces unit before moving into the CEO role. Donahoe wasn’t sold. The Chicago-area native didn’t fit the mold of a hard-charging, garrulous Silicon Valley executive. A graduate of Dartmouth College (where the 6-foot-5 economics major played basketball) and Stanford Business School, Donahoe had spent his career based in the Bay Area but had never worked at a tech company.
His successful run at Bain & Co. — he was worldwide managing director when Whitman approached him about the eBay gig — was notable for his efforts to balance family obligations with his high-powered job. When he was a young manager in Bain’s San Francisco office, his wife, Eileen, was offered a clerkship with a federal judge. The position would take time away from their two children, who were then 6 and 8. Donahoe was traveling weekly to clients in Texas; he told his boss at the time, Tom Tierney, that he’d need to quit his job in order to be available to his family. “Donahoe, you’re such an idiot,” Tierney told him, and then persuaded Bay Area-based Fireman’s Fund to hire Bain — and Donahoe — at no charge. Donahoe was able to look after his kids, and he eventually turned Fireman’s Fund into a paying client. The Donahoes now have four children, and Eileen works in Geneva, where she serves as the U.S. ambassador to the United Nations Human Rights Council. Donahoe says they talk every day by phone and try to coordinate personal and business trips.
Despite his misgivings about diving into the “hot” tech world (“I’ve never been hot in my life,” he jokes), Donahoe agreed to meet with Omidyar one rainy afternoon at the Hayes Mansion in San Jose. They talked about success being measured not by earnings but by long-term contributions to society. That evening Donahoe watched a company-produced video featuring the stories of buyers and sellers. He was moved to tears listening to how an eBay customer bought World War II dog tags, tracked down the owner, and returned them to him. eBay, he realized, was a business that actually did some good. He signed on in 2005 as president of Marketplaces and became CEO in March 2008, amid the global economic meltdown.
Donahoe knew eBay would have to make radical changes if it wanted to survive both the financial crisis and mounting competition. He eventually would announce eBay’s first significant layoff, 1,600 people, or about 10% of the workforce, and shed underperforming assets, including Skype. Just four days after being named CEO, he stood in front of eBay’s largest sellers and announced major changes to the site’s fee structure (it became cheaper to list items on eBay, but the company started charging higher rates when items actually sold) and imposing stricter rules on sellers in a bid to improve customer experiences. Then he shocked everyone by telling the world that eBay was in need of a turnaround. “Our sellers hated that word. Our employees hated it. Investors hated it. But it was the first step,” Donahoe says. “If we were not just going the way of every Internet company, we had to confront reality.”
Reality, in eBay ’s case, was the threat from tech-savvy web rivals. Starting in the mid-2000s, Google created challenges for eBay. The search giant’s increasingly sophisticated algorithms allowed consumers to bypass eBay altogether to find traditional retailers as well as individuals looking to sell used and vintage items online — eBay’s original core seller. Small online retailers realized they might not need the eBay platform after all. And so-called flash sales, or deal-a-day sites, emerged to capture the bargain hunter who wanted new, not gently used, items at deep discounts.
Bizarrely, eBay shrugged off Amazon, even after it launched the eBay knockoff Amazon Auctions. The auctions business never became a home run for the Seattle online retailer, but Amazon — in an effort to make shopping experiences more consistent for all shoppers — imposed strict regulations on its third-party sellers, a move Donahoe emulated in 2008 as part of his restructuring of eBay. Amazon’s insatiable desire to dominate all of retailing proved to be an opportunity for eBay — a chance for the platform to become a sort of Switzerland of e-commerce, helping retailers fend off a common foe. “eBay wants to partner with the market sellers of the world, not put them out of business,” says Devin Wenig, president of Marketplaces. Indeed, eBay doesn’t compete directly with its retail partners — it isn’t peddling books and shoes and diapers alongside them.
Thanks to PayPal, eBay already has a foot in the door with some millions of sellers. The payments business, which eBay acquired in 2002 to facilitate online purchases, processed $145 billion in payments last year, with about $14 billion in transactions completed on mobile devices. (PayPal accounts are linked to a bank account or debit or credit card.) Wedbush analyst Luria believes PayPal is largely responsible for the building excitement around eBay’s outperforming stock. Donahoe expects PayPal revenue to surpass that of eBay’s Marketplaces unit within the next three to five years as the company pushes PayPal into stores and as consumers become more comfortable using their phones to pay for items and transfer money. In fact, PayPal’s biggest competition may come from mobile-oriented payments companies such as Square, which in November said it is processing transactions at a rate of $10 billion a year. PayPal recently restructured, laying off 325 employees and 120 contractors, saying it aimed to speed up innovation.
PayPal is just one example of eBay’s aggressive push into mobile. Donahoe bet big and early on the idea that smartphones would transform the shopping and paying experience for consumers. In early 2009 he enlisted Steve Yankovich, a recent entrepreneur in residence at Adobe (ADBE), and gave him several million dollars in capital to assemble a mobile team and develop apps for the iPhone and other on-the-go devices. As Donahoe focused on turning around the rest of eBay, Yankovich was given a wide berth to build a team. The company’s apps, including a main eBay app, a car-buying app, and price-comparison app RedLaser, have been downloaded more than 120 million times combined. Coming soon? New “augmented reality” features that use a smartphone’s camera to let a user visualize how an item might look on her. Want to see if that watch is a good fit for you? Aim your phone at your wrist and special software will impose a digital version of the timepiece on your arm.
Donahoe believes that mobile phones will help blur the lines of physical and online retailing. Customers will use their phones to read reviews, search for bargain prices, and place orders via apps and websites. But they’ll also use their devices to find nearby stores where they can try something on, pick up an item, or even get same-day delivery.
MORE: Shopping the eBay way
eBay wants to be able to help retailers close sales with customers — no matter how they choose to browse, buy, and pay. Far from abandoning brick-and-mortar retailers, eBay is trying to become a bigger presence in stores — thus its deal with Discover to let customers check out using their PayPal accounts at the register. (Home Depot and Foot Locker (FL) already offer an in-store PayPal option.) Late last year eBay entered the same-day shipping fray with eBay Now, an app that lets users have items from retailers like Target (TGT) and Best Buy (BBY) delivered to their door in an hour. Currently available in New York City and San Francisco, eBay Now is expected to expand to other major cities in coming months.
Bill McComb, CEO of upscale retailer Fifth & Pacific, parent of Kate Spade, Juicy Couture, and Lucky Brand, says eBay has put together a smart portfolio that enables his brands to reach online shoppers quickly and easily. “eBay hasn’t been stupidly acquisitive,” he says. “They have really put together some smart people and highly differentiated tools.” Fifth & Pacific uses eBay’s GSI unit to operate its websites and provide analysis on the way consumers are behaving on, say, the Juicy Couture site. eBay is more than simply a tech vendor, though; its scale makes the company an appealing marketing partner to niche retailers like Kate Spade. And so last winter the accessories company tested two invitation-only sales on eBay Marketplaces to introduce the Kate Spade brand to a broader audience. The online “pop-up” stores offered just a sample of the Kate Spade inventory. McComb declined to disclose sales results but says he would tap into eBay Marketplaces in the future.
Of course, eBay isn’t the only company with a set of skills and technologies to help retailers figure out how to serve customers better. Google has a mobile payments platform and search tools, and it wouldn’t be a big stretch for the tech giant to build and manage retailers’ websites if it really wanted to do so. A handful of upstarts, including Shopkick and Perka, are working with big retailers to drive traffic to stores. And then there’s Amazon. “Amazon has assembled all the tools that, if they ever opened them up to retailers, would be big competition for eBay,” McComb muses. “But they’ll never do that.”
One of the ways Donahoe tries to stay abreast of changes in the tech world is by shadowing young entrepreneurs. Donahoe spent a day at Airbnb’s San Francisco offices last October to observe how founder Brian Chesky runs his room-rental company. (For more on Chesky, as well as Square’s Dorsey, see “The Trailblazers.”) Donahoe later invited Chesky to attend an eBay board meeting to explain his management style to the directors. “In a lot of people who are really senior and really professional, they want to have answers,” Chesky says of Donahoe. “But he had mostly questions.” Chesky motivated Donahoe to devote more time to thinking about how to use design to improve the eBay experience for customers. Donahoe took Chesky’s advice: eBay Now, for example, walks a consumer step by step through browsing for an item to purchase and delivery.
The user-friendly app design is part of a broader effort by Donahoe to improve the consumer experience at eBay. He pushed for a redesign of the website, ditching eBay’s stale Web 1.0 appearance for a more streamlined look that decluttered the product listings and other information. To give a user’s homepage results a fresh, current look, Donahoe created a mini-startup within eBay. He sent Jack Abraham, who resigned recently as head of local search operations, and five young employees from across the company to work remotely in Australia. They came back with a prototype that is the basis for the large, photo-driven stream of products eBay users trawl through today.
Donahoe and his team understand that they’ll need to attract more customers to eBay’s products to keep growing — PayPal can’t be its only hot property. Executives hope to double eBay’s 112 million active users during the next three to five years, in part by boosting cross-border trade and bolstering eBay’s international presence in countries such as China, which has not been hospitable to American online retailers. Late last year eBay announced eBay Style, a partnership with the luxury online retailer Xiu.com that lets Chinese consumers buy items from merchants outside the country. Meanwhile Xiu.com handles domestic tasks like shipping and customer service, helping eBay tap into the Chinese market while maneuvering the country’s challenging regulatory environment.
Donahoe is also painfully aware that success in tech is fleeting. For all the innovation that comes out of Silicon Valley, he cautions, only Intel (INTC), Cisco (CSCO), Apple, Oracle (ORCL), and HP have emerged as long-term survivors. What keeps eBay from changing course yet again — from becoming that fat, happy, out-of-touch company that Donahoe walked into eight years ago? Supporters say the antidote is Donahoe himself. Indeed, at a time when many CEOs might be congratulating themselves, Donahoe focuses on the work yet to be done. eBay, he tells Fortune, is a good company, but it is not yet a great one. To wit: Not enough eBay employees actually use its products. “I see competitors’ boxes coming to our mailroom,” he tells the team gathered at the San Jose Civic. “You should be using our products and using PayPal products wherever you see them.” Says Tierney, Donahoe’s former boss, who now sits on the eBay board: “What John has become extraordinary at is identifying and pursuing the right questions. ‘Are we in a turnaround?’ That turned out to be a really important question.” Perhaps the more relevant question today is, Is eBay’s turnaround complete? Many investors would say the answer is a resounding yes. Donahoe might say the company is in the middle of its journey.
This story is from the February 25, 2013 issue of Fortune.