FORTUNE -- By the usual measurements, Subaru should be no more than an afterthought in the U.S. car market. It sells just seven car and crossover models and accounts for a slim 2.3% of U.S. auto sales. By itself, the Toyota Camry outsells the entire Subaru lineup. For years Subaru has been essentially a regional brand -- strong in the Northeast and Northwest but unknown in the rest of the country. No overnight success, Subaru of America -- the U.S. arm of Japan's Fuji Heavy Industries -- began selling cars in the U.S. 44 years ago and still ranks only 12th in size. Hyundai and Kia, which arrived two decades later, have developed broader product lines and sell several times more vehicles.
Yet Subaru has racked up more endorsements by independent arbiters of automotive quality and safety than just about any other manufacturer. Consumer Reports rates Subaru above Mercedes-Benz, BMW, and every other manufacturer in performance, comfort, utility, and reliability, and says the company makes the best cars in America. ALG (formerly Automotive Lease Guide), the industry's arbiter of residual value and used-car prices, named Subaru the leader in retained value among mainstream brands. And after crash tests, the Insurance Institute for Highway Safety made Subaru a "top safety pick" across its entire product line, a distinction no other manufacturer can claim.
Fueled by this trifecta of achievements, just about everything Subaru sells is flying off dealers' lots this year. Despite a chronic shortage of inventory, the company has been breaking monthly sales records with regularity, and sales for the year are up 26% compared with last year's -- nearly double the 14% gain for the industry as a whole. Hurricane Sandy struck right in the heart of Subaru's customer base, yet the little car company saw sales jump 30% in October, vs. the industry's 7%.
What Subaru has done is to make itself into the first automaker that could be described as "artisanal" -- focused, individualistic, and really good at a very few things. With only limited resources, Subaru has made smart bets on features like all-wheel drive, developed memorable marketing and advertising that set it apart from the competition, and learned more about its customers than any other automaker. In appealing to them by geography, lifestyle, and, at times, sexual orientation, it has built the deepest loyalty in the car business. The company understands itself so well that for years its advertising tag line was the self-referential "It's what makes a Subaru, a Subaru."
So resilient is the appeal of its brand name that Subaru has managed the feat of stretching it over wildly different models. One of this year's fastest-selling cars has been Subaru's compact Impreza sedan and hatchback. Newly redesigned and with a base price under $18,000, it has young families and first-time buyers queuing up to take advantage of its improved fuel economy, updated styling, and roomier interior. Sales have doubled from a year ago, and dealers have less than a two-week supply. At the opposite end of the functionality spectrum is another red-hot seller, the Subaru BRZ. A modern interpretation of the classic sports car, the two-plus-two coupe features out-there styling and racetrack handling that appeal to men of a certain age. So many are going out the door at prices starting at $25,000 that the days' supply at the beginning of September had shrunk to 11.
It's unusual for any car company, let alone one as tiny as Subaru, to have two hit models at once.
Today Subaru finds itself in a market sweet spot that produces outsize profits because, like an NFL receiver, it has learned how to work the seams. In the overcrowded midsize segment, for instance, Subaru sidesteps heavyweights like Camry, Accord, and Altima by equipping the Legacy with all-wheel drive (AWD), which the others don't offer. It can dodge expensive incentives because its cars are in short supply and its relatively affluent buyers are less sensitive to promotions. In August, Subaru spent just $857 per car on incentives; only Porsche spent less. Edmunds.com senior analyst Jessica Caldwell says Subaru customers are generally capable of affording a more expensive vehicle, don't buy strictly on price, and continue shopping even when the economy takes a dive.
Even so, life isn't easy for Subaru or its corporate parent, Japan's Fuji Heavy Industries. They are minnows in an industry where size counts. Don't look in Subaru's lineup for any minicars the size of the Honda Fit or for full-size ones like the Toyota Avalon either. All Subaru cars and crossovers are based on just two platforms (General Motors (GM) has 30!), and the vehicles range in size only from subcompact to midsize. Subaru needed to form a partnership with Toyota (TM) to make the BRZ economical. Subaru did most of the engineering and provided the engine, but Toyota created the design and markets an almost identical version called the Scion FR-S.
Tom Doll, Subaru's top U.S. executive, in a Forester
Small size hurts when a new model like the awkward seven-passenger Tribeca fails to gain a foothold. It's also hard for a small car maker to keep on top of new technology. Subaru's signature four-cylinder "boxer" design is two decades old, and the company's first hybrid car won't come out until next year, 15 years after Toyota's Prius went on sale. Subaru suffered a near catastrophe when the earthquake and tsunami in March 2011 closed factories in Japan for four weeks and interrupted the flow of parts to its sole U.S. plant, in Lafayette, Ind. Dealers were starved for cars. Used to operating with 32,000 cars on the ground, Subaru saw its inventories drop to 17,000, pummeling sales.
Subaru recovered but now faces fresh challenges. It needs to catch up with competitors by developing fuel-efficient powertrains across its lineup, opening more factories outside Japan to spread its currency risk, and expanding its U.S. sales footprint. And it has to keep looking over its shoulder. Fast-rising Volkswagen poached Subaru's top marketing executive a year ago, and according to industry reports, VW is considering a new crossover with ride height, bumpers, and wheel-arch cladding that takes dead aim at Subaru's most popular models.
So Subaru will have to find new ways to differentiate itself, which shouldn't be much of a stretch. Since its founding, it has always gone its own way. Its headquarters are in a New Jersey suburb, several thousand miles away from its Japanese competitors in Southern California. While former sales managers and marketing experts sit atop most import car companies, Subaru's highest American executive is an accountant who started at the company as an assistant treasurer. And Subaru's product history is studded with oddities like the BRAT, a mini-pickup with rear-facing jump seats bolted to the rear bed to circumvent a tariff known as the chicken tax; the Justy, which Top Gear said "manages the impressive feat of being as boring as its name promises"; and the Baja, a station wagon, built with an open cargo bed in place of a rear compartment, which one reviewer compared to a platypus.
Subaru of America was started in 1968 by two entrepreneurs, Malcolm Bricklin and Harvey Lamm, who contracted with Fuji Heavy to import cars as the initial wave of Japanese imports was washing onto U.S. shores. Their first car was the 360, a minicar with a 25-horsepower engine that needed 37 seconds to get from zero to 50 miles per hour; Consumer Reports called it the "Most Unsafe Car in America." But by selling distributorships, SOA went on to become the only import car company that was publicly traded; it made small fortunes for its two founders. Bricklin went on to build his own eponymous safety car, imported Fiats and Yugos, and was last seen trying to make a deal to import China-built Cherys.
Despite its rocky start, Subaru clung to its tiny niche like a freestyle rock climber on El Capitan. It introduced an AWD system in 1972 and continually upgraded its boxer engine. Its marketing and advertising cleverly exploited the brand's offbeat appeal. After it won the endorsement of the U.S. ski team in 1976, the company broadcast a commercial showing a Subaru driving up a snow-covered ski jump. Subaru was also a pioneer in reaching out to gays and lesbians, recently advertising on television shows like The L Word.
Still, its existence remained precarious. Subaru nearly collapsed in the 1980s when it tried to challenge Toyota, Honda, and Nissan in the mainstream car market with a lineup of sedans and sports cars sold under the slogan "Inexpensive and built to stay that way." When the yen rose late in the decade, the price of made-in-Japan Subarus exploded, and its high-volume strategy collapsed. Its sales, which had peaked in 1986 at 183,242, fell all the way to 100,407 by 1995, and nobody would have been surprised if Subaru had left the U.S. market. (This year sales are expected to be 325,000.)
Subaru advertising has emphasized the cars' offbeat -- and off-the-road -- appeal.
Instead, it made two important decisions that continue to resonate today. It decided to equip all the vehicles it sold in America with all-wheel drive. It also created a high-trim version of its Legacy station wagon with SUV design cues, named it the Outback, and hired Paul Hogan of Crocodile Dundee fame as its spokesperson. Billed as "the world's first sport-utility wagon," the Outback was slow to catch on, but its sales have grown fourfold since 1996. It has gradually morphed from a station wagon into a true crossover -- high roof, raised suspension, beefy bumpers -- but remains Subaru's biggest seller.
Subaru was becoming known as a quirky, likable product with a workaday attitude. But awareness and sales slipped throughout the 1990s and early 2000s, in part because Fuji had decided that Subaru's AWD technology deserved a premium price. Even though the Subaru brand was soundly locked in the Japanese mid-tier along with Mazda and Mitsubishi, Fuji felt that since its car was technically equivalent to an Audi, it should sell for a similar price. It took some convincing by American executives, but in 2007 the pricing was gradually readjusted, smoothing transactions on the sales floor and improving resale values. When the 2009 Forester was introduced, for instance, the base price was cut by $1,200.
Sales responded to the change almost immediately, and by 2010 Subaru had passed 260,000 vehicles a year. The repricing was a victory for executive vice president Tom Doll, a 30-year Subaru vet and its top American executive, who had long argued for the change. Methodical and even-keeled, Doll joined Subaru after five years at the old Big Eight accounting firm of Arthur Young, and rose steadily through the company in treasury operations, strategic planning, and finance. Doll knows Subaru so thoroughly that he now serves as both chief operating officer and chief financial officer -- an unusual doubling of responsibilities for an executive in an $8 billion company. He runs it by the book. "We like to play it straight," he says. "We don't goof around."
Under Doll, Subaru is executing a strategy of controlled expansion designed to boost unit sales and build profit margins. It has created an Outback-like version of the Impreza called the XV Crosstrek that it will sell for a premium price after raising the suspension and adding new bumpers and plastic body cladding. And it is giving its performance models, now known as the Impreza WRX and Impreza WRXSTI, standalone identities by dropping the Impreza name. The move should boost brand recognition in places like Southern California, where these high-horsepower cars with bulging hood scoops and flared stabilizer wings are Subaru's highest-profile vehicles, and also make it easier to justify the $8,000 price bump over the standard Impreza model.
Asked what's missing from his model lineup, Doll says a seven-passenger vehicle. In a rare misfire, Subaru put on sale the B9 Tribeca, a midsize crossover, in 2005. Aside from its unfortunate name, the Tribeca introduced what was intended to be a new design language with a rounded body and odd triangular grille. The B9 part of the name was dropped, and the ungainly design got a quick face-lift, but the Tribeca has never caught on. Doll blames its failure partly on the seven-passenger designation; the two seats in the third row aren't big enough to fit adults comfortably.
Doll is trying to expand Subaru's geographic base. He aims to generate 20% of sales in Sun Belt states in the next two years, up from 9% two years ago and 15% now. He has been scooping up former Saturn dealers, adding eight in the Carolinas and Florida. Subaru is shooting for a nationwide network of 630 dealers by 2015, compared with 620 today.
Subaru is slowly building its manufacturing capability in the U.S. At the Lafayette plant, it is investing $75 million in a 52,000-square-foot addition to the body-assembly section this summer. That will increase the plant's capacity to 180,000 vehicles a year, vs. 156,000 now.
With Subaru on a path to reach its U.S. sales goal of 320,000 units for 2012, Doll has mapped out a strategy that he expects will lead to sales of 350,000 units by 2016 while maintaining a market share of at least 2%. He's not changing his philosophy: The inventory of cars will remain tight. Subaru is currently running with a 45-day supply, compared with the 65 days that are considered optimal in the auto industry, and Doll plans to keep it that way. "Inventory is the kiss of death and the root of all evil," he says, only half-jokingly.
His expansion plans are getting a boost from Fuji, which is crashing a program to modernize its technology with the aim of boosting fleet-wide fuel efficiency by 30% by 2015. It has introduced a third-generation boxer engine (Subaru's first entirely new engine in 20 years), and is developing hybrid powertrains and fuel-thrifty continuously variable transmissions (CVTs).
The success of the BRZ underlines one question mark about the future of Subaru that could be both an asset and a liability: its ties with Toyota. Besides designing the sports car and sharing space in the Indiana plant, Toyota owns 16.5% of Fuji Heavy, having doubled its stake in 2008. Further cooperation could give Subaru access to technology and speed its expansion into global markets. The risk, of course, is that the giant company would squeeze the individuality out of the smaller one. The partnership will be successful only if Toyota remembers what makes a Subaru a Subaru. It is a lesson that has taken Subaru a long time to learn and one that it has no intention of forgetting now.
This story is from the December 3, 2012 issue of Fortune.