When will I be able to get wheatgrass in my smoothie? Do you sell dehydrated pineapple? They want how much for this organic coconut oil? It is the kind of earnest banter you might hear at any Whole Foods Market WFM store in Manhattan or San Francisco — only these snippets were among the full-on foodie conversations picked up in the aisles of Whole Foods’ lone store in Detroit, a gleaming 21,000-square-foot food and natural-products emporium that opened in June 2013, six weeks before the city filed for bankruptcy protection.

Detroit’s financial affairs and its struggling population (42% live below the poverty line) make the city an unlikely spot for the upscale grocer. But if not for the local touches — the lights over the checkout lines are made from repurposed Motown records and the walls are decorated with murals by Detroit artists — you’d be hard-pressed to distinguish the store from any of Whole Foods’ 374 other locations. It has the same overwhelming variety — 19 types of honey, 13 kinds of chicken or turkey sausage — and dizzying range of products. If you have $20 to spare, you can buy a “conventional” (industry-speak for nonorganic) bonsai plant or cough up $22.99 for acai powder. The more cost conscious can find a can of cannellini beans or a one-pound bag of pasta for under a dollar.

Translation: Whole Foods didn’t alter or dumb down its formula for Detroit, and why should it? The Austin-based chain is one of the country’s most successful retailers — its revenue has doubled and profits have tripled since 2007 — defying dismal grocery industry trends by offering consumers a mix of organics, truly delicious prepared foods, and an expanding array of staples under its 365 house brand. Now, having conquered affluent suburbs and trendy urban areas, Whole Foods is out to win over the rest of America, setting up shop in previously unthinkable places such as Detroit and Boise, and opening multiple locations in existing markets both large (San Francisco and Manhattan each have seven) and small (two apiece in Tulsa and West Hartford, Conn.).

This may come as a surprise to those who still think of the retailer as “Whole Paycheck,” an overpriced natural-food haven for yoga-practicing, juice-cleansing Prius drivers or hipsters obsessed with artisanal baking soda. And while Whole Foods’ prices are rarely the cheapest in town — and, yes, you may very well run into a Lululemon-clad hybrid driver in the checkout line — it’s appealing to a wider array of shoppers than ever before. When Whole Foods went public in 1992 with 10 stores, co-founder and co-CEO John Mackey thought perhaps the chain could open 100 locations, and even that goal, he tells Fortune, was “outlandishly optimistic.” In December he upped Whole Foods’ projected U.S. store count to 1,200, from an earlier plan of 1,000. (The company also operates stores in Canada and the U.K.)

MORE: 6 great teams that take care of business

Whole Foods’ vision is a bold gambit when you consider the state of its competition. Supermarkets lost 10 points of share between 2001 and 2013 to the slew of nontraditional players that have gotten into the food game, according to Nielsen. (The erosion finally has started to slow.) Wal-Mart WMT , for example, calls itself the nation’s largest grocer, with $156.5 billion in its U.S. division’s sales coming from grocery, up from $137.8 billion in fiscal 2010. Whole Foods, with $12.9 billion in sales, is tiny by comparison, but it’s had an outsize impact on the industry and defied the headwinds facing its brethren by dominating in the food category that’s growing — one that, not coincidentally, it helped create. Healthy, organic, and natural products, a segment few know better than Whole Foods, make up an estimated $150 billion market that’s expected to grow by about 50% by 2018, according to industry tracker Penton’s Next division. “They’re a leading national authority on health and nutrition,” says BB&T Capital Markets analyst Andrew Wolf, “and unequivocally the leading retailer on the link between food and health.” That lead has translated into healthy stock market gains: The share price is up about 12-fold since its November 2008 recession-era low, vs. 130% for the S&P. Amazingly, much of the senior team leading the corporation has worked together or known each other since the company’s early days.

Whole Foods has borrowed from the playbook of traditional supermarkets while avoiding their pitfalls. It’s built out a successful, value-oriented private-label program but has maintained a stringent list of banned ingredients for the products it stocks. It has managed to keep its stores and inventory from being commoditized by localizing each location and perpetuating the novel idea that a visit to the grocery store can be not only painless but also pleasant. At the San Francisco Market Street store, for example, you can check out the pop-up oyster-shucking station after you get your shoes shined. In Brooklyn you can enjoy a local craft brew on a rooftop bar next to a 20,000-square-foot greenhouse.

MORE: 5 secrets to building killer teams

To be sure, Whole Foods has never been easy to love unconditionally, while rival Trader Joe’s has secured an unabashed cult following. On one end of the spectrum, it has irritated the customer who couldn’t care less about its animal-welfare standards and is peeved that she can’t find Diet Coke; on the other end, plenty of Mackey’s fellow vegans think he’s a hypocrite for selling meat and dairy products. It has dropped popular brands, such as Chobani, causing consumers to scratch their heads. And Mackey, a vocal libertarian, has challenged the public’s expectations of what a health-food CEO’s politics should be.

But consumers flock to Whole Foods nonetheless — to the tune of more than 7 million customer visits per week. And the chain enjoys a popularity and buzziness that previous “health food” stores never achieved. That’s because Whole Foods preaches healthy eating but doesn’t judge. It lets us feel good about the food we buy without forcing us to live an ascetic, fringe lifestyle. It makes flax seem less scary. Kevin Kelley, whose consultancy Shook Kelley has done work for Whole Foods, says the company embodies the idea of the “healthy indulgence.” You can buy vegan cheese at Whole Foods, but you can also buy cheesecake. “They’ve changed how we think about food, our relationship with food, and our questions about food,” Kelley says. Says co-CEO Mackey: “We’ve helped people to see what’s possible, and re-envisioned what a supermarket is.”

The precursor to the first Whole Foods was Safer Way, a health-food store that Mackey and his then-girlfriend ran out of a Victorian home in Austin. The store didn’t sell meat, sugar, or caffeine — a reflection of Mackey’s food ethos at the time. “We were really hardcore, but we didn’t do very much business,” Mackey says. He knew he’d have to attract a broader base of customers if he wanted to run a real grocery store, not just be the food police. “The interesting thing about building a successful business is that you do help change things,” he says. “But on the other hand, if you’re not going the way people want to go, you won’t be successful.”

MORE: Wal-Mart goes (somewhat) organic

The idea that natural and organic foods were a healthier alternative was still countercultural when Mackey cofounded Whole Foods in 1980. The first store was a success by health-food standards, but it wasn’t in the same league as a supermarket. He likes to tell the story of how one venture capitalist said, as he declined to invest, “I think you guys are just a bunch of hippies selling food to other hippies.”

To expand, Whole Foods started buying up small natural-food chains, such as North Carolina’s Wellspring Grocery, Bread & Circus out of New England, and Mrs. Gooch’s in California. But when the company pursued Colorado-based Wild Oats in 2007, the Federal Trade Commission tried to block the acquisition. Whole Foods prevailed, but it was such a painful experience that management shifted more toward opening new stores rather than buying existing ones. Another lesson: Wild Oats had found success in smaller communities, which helped Whole Foods executives recognize the opportunity to peddle quinoa and organic Swiss chard in cities like Little Rock and Tulsa.

The real estate team has learned the hard way that some second-tier cities often have more potential than initially thought. The company picked a spot right in the center of town for its first, and what management thought would be its only, 50,000-square-foot store in Omaha. Now Whole Foods believes the market could support three locations there. But with one already right in the heart of the city, it’s hard to figure out where to put the other two. So when securing a site in Des Moines, Whole Foods went for West Des Moines with the thought that the population could support another store on the other side of the metro area. “We’re putting stores closer together than we ever thought possible,” says Jim Sud, who heads up growth and business development. “We find that there’s some initial cannibalization, but then we quickly recoup that, and the size of the overall market continues to grow.” In January when the company launched its fifth location in the Austin area, its oldest market, the store had a record-breaking opening day despite being less than two miles from another site.

MORE: End of the ‘gig economy?’

Traditional grocery principles don’t always apply to Whole Foods, so it’s had to create its own. Sud and his team at one time used a variation of the supermarket industry standard, the gravity model, to predict sales volumes when considering a new store. The gravity model takes into account all the grocery business done within a certain trade area and assumes a new store will gain a percentage from each competitor. But sales at new Whole Foods stores kept outstripping the gravity model’s projections. “What we’ve found is Whole Foods creates volume that isn’t really there,” Sud explains. Now the company uses its own proprietary model.

The density of college graduates used to be the best indicator of whether an area’s consciousness was ripe for a Whole Foods. While that’s still true, “consciousness has gone beyond just being well-educated when it comes to healthy food,” Mackey says. “Now I would say, give us enough population density in an area, and we’ll get our share and we’ll be successful. Detroit and New Orleans already proved that, and Newark and inner-city Chicago and some of the other markets we’re looking at will just reaffirm that.” Mackey still views Whole Foods as a niche retailer — it’s just that its niche has gotten bigger.

Even with a more accurate model for projecting sales volume, a Whole Foods in Detroit wasn’t supposed to work. Analytically it made no sense. “I was definitely one of the most skeptical people,” Mackey says. His co-CEO, Walter Robb, was the one who championed the Detroit store. Whole Foods is a purpose- driven company, and Robb wanted to explore how it could reach people who hadn’t traditionally been seen as Whole Foods customers. “This criticism of organic food and natural food as being an elite thing, or only for some people, was really gnawing on me,” he says.

MORE: Freelancer pay jumps, in search for quality work

Robb and Midwest regional president Michael Bashaw visited Detroit in June 2010 to check out the city’s urban agriculture movement. Amanda Musilli, a native Detroiter and marketing team leader for the Michigan stores, showed them around, and afterward they asked her to start investigating the city’s culinary scene. “Once we started to learn about Detroit,” she says, “we saw people who were incredibly passionate about food.” For Whole Foods it wasn’t about creating a food movement in the city but about tapping into one that was already there. Musilli and her team canvassed churches and libraries, inviting people to discussions on a potential Detroit store. “We knew we had to take a new approach and be more inclusive in Detroit,” she says. Dr. Akua Woolbright, a senior healthy-eating and wellness educator for Whole Foods, taught free classes on topics like combatting food cravings and decoding food labels. Often she wouldn’t even mention her employer. (She’s still teaching classes for free.)

A lot of Detroiters already knew Whole Foods and drove out to the suburbs to shop at its stores, but concerns lingered. Community members told Musilli and her team that they often got the poorer version of businesses. They felt that stores in Detroit weren’t kept clean and that service was lacking in comparison with their counterparts around the state. They didn’t want bulletproof glass or bag checks. They wanted a real Whole Foods.

Despite the city’s seemingly endless vacancies, the team struggled to find the right site. Lots and existing buildings were often too small. Executives in the end decided to raze an old Chase bank to build a new 21,000-square-foot store (the company average is 38,000 square feet) in a revitalized part of the city near Wayne State University and the Detroit Medical Center. Building-design options were made public earlier in the process than normal so that the community could weigh in. Musilli hired buses to take Detroiters out to Whole Foods’ suburban locations so that they’d have a better sense of pricing and possible features for their Whole Foods. (A smoothie bar got a resounding yes; Kale Kick-Start is the top seller.)

MORE: 100 Best Companies to Work For – Whole Foods

Since Michael Pollan criticized Whole Foods in The Omnivore’s Dilemma for its lack of local product, the company has tried to bring smaller neighborhood businesses into its supplier mix. In the Detroit store you can find goods made by 30 different homegrown vendors. Whole Foods partnered with local bakery Avalon to supply half of the store’s baked goods and selected it as a recipient of the company’s local loan program to help build out its operations. A handful of suppliers were recruited from Eastern Market, a Detroit neighborhood that is home to a vibrant public bazaar. Among them: Spice Miser, which sells small packets of spices for 99¢, and dried fruit and nut purveyor Germack. Some would-be vendors tweaked their products to meet Whole Foods’ quality standards: Water Station, about 10 minutes down the road, took the coral calcium (a salt of calcium) out of its alkaline water. Gluten-free goody maker Ethel’s Edibles started using fruit without sulfites, cage-free eggs, and hormone-free dairy. Being in Whole Foods “has given us crazy credibility,” says Ethel’s founder and president, Jill Bommarito.

Despite the good feeling conjured by Whole Foods’ entrance into the city, it’s still a business endeavor. Executives decided to lower the margin structure and pricing for Detroit, but almost a year in, the store is exceeding expectations and is profitable. Its patterns follow the rest of the company’s locations, which see about 30% of sales from organic products and 12% from Whole Foods’ exclusive brands. Prepared foods are doing better than expected. The team has worked to highlight value, such as $5 Panini Thursdays and the bulk-foods section, where customers can buy only what they need. A shopping trip to a local grocery store reveals that prices at Whole Foods are comparable.

MORE: Patagonia expands in food

Robb believes that the Detroit store is one of the most meaningful things Whole Foods has ever done. But it has also taught the company a lot about how to serve broader areas — about being more affordable and balancing quality and value. After the Detroit store opened, Robb says, Chicago Mayor Rahm Emanuel personally called him to ask Whole Foods to come to the South Side of his city. Newark is getting a Whole Foods in 2016, thanks in part to the lobbying efforts of New Jersey Sen. Cory Booker, who, as the city’s mayor, told his staff it was the holy grail, the mark not of an area that was “coming back, but that had arrived.” “Success in Detroit has a lot of implications for the company’s growth into the future,” Bashaw says. “This has caused us to rethink what’s possible and question the assumptions that we’ve always made about the economic analysis.”

The core competency of Whole Foods is, put very simply, food. That might seem a given for a grocery store, but most often it’s not the case. Supermarkets are “wired for distribution and warehouse and logistics,” says consultant Kevin Kelley, “not customers or a vision for food.” Most chains try to carry everything anyone could possibly want, but Whole Foods has an opinion on what it should stock. “Great brands impose a view on you,” Kelley says, and Whole Foods is no exception. “One of the faults that traditional groceries have is they believe the customer is always right.”

MORE: Say goodbye to your supermarket

Whole Foods has no problem telling the customer that the store knows best, and it has become skilled at using its scale to prod change. When the company started in 1980, it already had a mantra of no artificial colors, flavors, or preservatives. “That was a real change for shoppers — to go into a store that they already knew had used that as a filter,” says Margaret Wittenberg, the company’s global vice president of quality standards. Today Whole Foods has a list of 78 banned ingredients, ranging from aspartame to foie gras to high-fructose corn syrup.

The company often uses its bully pulpit to influence suppliers. It demanded that its cleaning-supply vendors list on their packaging all ingredients, even though federal law does not mandate it. Similarly Whole Foods last year said it would require all its vendors to label products with GMOs by 2018, in part because, Wittenberg says, the U.S. Department of Agriculture had been dragging its feet on issuing rules about labeling. “We often ask this question: If we’re not willing to do this, who’s going to do it?” Mackey explains. “In a lot of these issues we take a leadership position because we don’t see anybody else doing it.” He adds with a laugh, “We take the heavy blows, and then if it works, people follow.”

Indeed, as the organic movement has caught on, Whole Foods’ competition has jumped on the bandwagon. Grocery powerhouse Kroger KR has said that it’s the second-largest seller of natural food — after Whole Foods. Wal-Mart and Target TGT offer a smattering of items once found only in health-food stores. In fact Whole Foods missed earnings forecasts in the most recent quarter and in part blamed increased competition.

MORE: Who will occupy RadioShack’s retail desert?

Whole Foods is capitalizing on its existing organic cred as it expands its private-label 365 brand, which offers conventional and organic varieties. The brand is now available in nearly 2,000 stock-keeping units and is often the lowest-priced and bestselling item in a category. Customers traditionally have looked for organics on the perimeter of stores where fruits, vegetables, and meat are stocked. But the price and abundance of 365 products has encouraged customers to go organic when selecting packaged goods, says A.C. Gallo, Whole Foods’ president and chief operating officer. This assortment of trusted “generics” has enhanced another of Whole Foods’ growth strategies: converting casual shoppers — those who come in for a few specialty items — into hardcore regulars who make the majority of their food purchases at the store.

Whole Foods’ takeover of America is hardly assured. While the 365 brand is easy, or at least easier, on the wallet, the view that Whole Foods is overpriced still lingers. The company lost major points on “price satisfaction” in a recent Consumer Reports supermarket ranking. Not that Whole Foods wants to go too far downmarket. Even as the company aims to reach different consumers and enter new territory, a big part of its luster comes from being an aspirational brand. (“This week, let’s make homemade curry paste!”) Perhaps the biggest risk is being a victim of its own success: Shoppers may get their first taste of kale chips, jicama, and kombucha at Whole Foods, and then go online to have those foods delivered via Amazon AMZN or through outfits such as Fresh Direct, a New York-based company that does home delivery in five states. Hot web subscription service Blue Apron offers a prepackaged box of seasonal ingredients and recipes shipped to consumers’ homes.

MORE: How to fail in business while really, really trying

What the online competitors cannot replicate is the in-store extras that have turned Whole Foods into a destination. And that may be the company’s biggest edge as it moves into smaller cities and underserved neighborhoods. Despite technology (or perhaps because of it), people are looking for places to congregate and share a common love of food. “Grocery shopping for the longest time was a chore people did, like taking out the garbage or doing the laundry — something you had to do but something you didn’t really look forward to, something you didn’t enjoy,” Mackey says. “That’s completely the opposite of what food is. Think about it: Food, arguably, over our lifetimes, even more than sex, probably gives us more total pleasure in our lives than anything else, and yet people don’t like to go to the grocery store. My gosh! Isn’t that an interesting paradox?”

At the Detroit store, customers from all over the city come together to eat at the breakfast bar, check out the produce, and, yes, complain about the price of organic coconut oil, just as they would at any Whole Foods. A Whole Foods thriving in Detroit may be surprising, but there’s nothing paradoxical about it.

This story is from the April 28, 2014 issue of Fortune.