At some point over the last 15 years—sometime, say, between the 1999 release of “I Want It That Way” by the Backstreet Boys and last year’s “Roar” by Katy Perry—it became an inescapable fact that if you want to understand American pop music, you pretty much have to understand Sweden.

Songwriters and producers from Stockholm have buttressed the careers of Lady Gaga, Madonna, Usher, Avril Lavigne, Britney Spears, The Backstreet Boys, Pitbull, Taylor Swift, One Direction, Maroon 5, Kelly Clarkson, and any number of other artists you’ve probably listened to while dancing, shopping, making out, or waiting on hold over the past decade. (And it’s not just American pop music that has Scandinavian fingerprints all over it: When Azerbaijan won the Eurovision contest in a 2011 upset, they did it with a song written for them by two Swedes.)

If Americans are aware of this phenomenon, it is probably because they’ve heard about the legendary Swedish producer and songwriter Max Martin. There are any number of ways to express Martin’s ubiquity, but here’s one: From 2010 to 2011, the pop idol Katy Perry spent an unprecedented 69 consecutive weeks in the Billboard top 10, surpassing the previous record-holder, the 1990s Swedish group Ace of Base, by four months. But the milestone was far more of a testament to Martin’s staying power than Perry’s: Not only did he help produce and write all but one of Perry’s record-breaking string of hits, but he began his career as a producer for Ace of Base. Max Martin has produced more number-one songs than anyone besides George Martin, the so-called fifth Beatle.

But Max Martin is not some kind of unicorn. Other Swedish producer-songwriters boast only moderately less impressive résumés: Anders Bagge, Andreas Carlsson, and Rami Yacoub, to name just a few, have likewise worked with incredible rosters of American pop stars. And even focusing on this shortlist of talent obscures a much larger infrastructure at work.

What Hollywood is to movies and what Silicon Valley is to computing, Stockholm is to the production of pop.

Sweden, and in particular Stockholm, is home to what business scholars and economic geographers call an “industry cluster”—an agglomeration of talent, business infrastructure, and competing firms all swirling around one industry, in one place. What Hollywood is to movies, what Nashville is to country music, and what Silicon Valley is to computing, Stockholm is to the production of pop. In fact, Sweden is the largest exporter of pop music, per capita, in the world, and the third largest exporter of pop overall. And in recent years, the country has seized not just the message, but the medium as well: As the industry moves toward a distribution model that relies on streaming music services, the Stockholm-born Spotify is a dominant player, with 24 million users per month.

So how did Sweden, a sparsely populated Nordic country where it’s dark for much of the year, become a world capital of popular music? Rarely does such a complex question lead to such a satisfying answer: Three-quarters of a century ago, Swedish authorities tried to put a stop to the pernicious encroachment of international pop music, and instead they accidentally built a hothouse where it flourished.

IN THE 1940s, CHURCH leaders and cultural conservatives in Sweden rallied together around a solemn mission: to safeguard the country’s youth against the degenerate music—the “dance-floor misery”—that was being piped in from America. To combat this threat, the country built one of the most ambitious arts-education programs in the West.

Municipal schools of music spread across the country, offering morally uplifting instruction in classical music. Many of the schools, which were often free to attend, allowed students to borrow instruments, as if from a public library, for a nominal fee.

The aesthetically conservative intent of the municipal schools created an extremely democratic form of education. Because their purpose was to inoculate the masses against the corrosive effects of popular entertainment—and not to train a select group of virtuosos—the schools were widespread and accessible to children of all talent levels. (Fees have become more prevalent over the years, and currently run about $100 per semester.) When the schools’ curricular offerings began to diversify in the 1960s, Swedish students gradually started studying the very genres the schools were built to stifle.

Judged against their original purpose, Swedish municipal music schools have been a total failure. An initiative that started out as an antidote to the licentious sounds of Glenn Miller, Benny Goodman, and the like, instead set loose a musical juggernaut that would help give the world such hits as Katy Perry’s “California Gurls” and Britney Spears’ “If You Seek Amy” (try saying it out loud: F, U, C...). As the super-producer Max Martin once said, “I have public music education to thank for everything.”

On the most basic level, municipal music schools increased the odds that Swedes would discover their talents, while also giving the country an unusually music-literate domestic audience. Other knock-on effects were less obvious. The municipal schools provided an indirect subsidy to the music industry itself, for instance, by offering a steady supply of flexible teaching jobs to musicians. “Whether it was 10 hours a week or full-time,” says Christian Helgesson, a management consultant and former musician who has studied Sweden’s music industry cluster, “many of the musicians I knew during the ’80s and ’90s were able to participate.”

Eventually the aesthetics of Swedish music education came around to strikingly modern sensibilities. In the United States, the repertoire of primary and secondary music education still leans heavily toward the marching band. In Sweden, by contrast, rock and pop have been part of the curriculum in music schools since the 1980s, and in the 1990s courses in mixing and recording became available, too.

Outside the classroom, the government also encouraged young musicians with subsidies for practice space and even practice itself. “Every time we rehearsed, we’d get a couple dollars an hour,” says Ludvig Werner, a former musician and now the managing director of the music-industry group IFPI Sweden. Musicians couldn’t use the subsidy to pay their bar tabs; the money was earmarked for music. “You could use it to buy strings,” Werner says.

And perhaps most importantly, Sweden’s municipal schools gave rise to social networks of musically inclined youth—networks that ultimately formed the basis for the Swedish capital’s music industry cluster.

According to AnnaLee Saxenian, the dean of the School of Information at the University of California-Berkeley and an expert on talent markets and regional comparative advantage, these kinds of geographically intimate ties are crucial. “So much information is transferred in bars, informal institutional settings, in social networks, and in the movement of people between firms,” she says. Sweden’s capital city was especially conducive to this kind of transfer. “The size of Stockholm is probably perfect,” Helgesson says. “Everyone knows everyone. If you go into a music store to buy strings, you know the clerk because you played with him when you were little. If you go to a record label, you know the people there.”

FOR A LONG TIME—until the mid-1970s or so—Sweden was regarded by the international music industry not primarily as a source of great talent, but as a source of great consumers. “British and American rock acts became popular in Sweden earlier than in other non-Anglo countries,” notes the geographer Ola Johansson in a recent study of the country’s trajectory toward pop dominance. Because the Swedes were such reliable early adopters, Johansson writes, foreign promoters began to see the country as a test market for bands looking to break out of their home countries. The Beatles and the Sex Pistols both made early experiments in international touring in Sweden. (Meanwhile, cultural authorities in Sweden worried openly that foreign hits threatened to crowd out domestically made music. Indeed, one impetus for the country’s system of music-industry subsidies, in the beginning, was to combat this cultural trade deficit.)

One of the early conduits for foreign music was a pop-infatuated young music teacher and songwriter named Stig Anderson, born in the small town of Hova in 1931. Beginning in the 1950s, Anderson made a business of picking up international hits off of Radio Luxembourg, acquiring the rights, translating the lyrics, and assigning the songs to domestic musicians to record them for the Swedish market.

By 1972, Anderson was both a successful songwriter and manager. But he would become best known for assembling the four members of ABBA. The band’s rise to global popularity was a watershed moment in Swedish music—marking out the country’s potential as a major exporter of hits. (Last year, ABBA’s Gold surpassed Sgt. Pepper, in terms of lifetime sales, in the Beatles’ own country.)

“Role models are extremely important,” Werner says. “ABBA convinced people that ‘if they can do it, so can I.’ They were a fantastic boost to the industry.” The group also left a more concrete legacy. At the peak of their fame, ABBA built the cutting-edge Polar Studios in Stockholm, often compared to Abbey Road and Sun Studios. (Led Zeppelin recorded their final studio album there.) And Anderson personally endowed the prestigious Polar Music Prize, a cross between the Grammys and the Nobel that awards a substantial sum of money—around $150,000—to one pop musician and one classical musician every year.

By the 1990s, Ace of Base had taken the torch from ABBA, and the heart of the Swedish music scene was Cheiron Studios, co-founded by Max Martin’s mentor, Dag Volle, a.k.a. Denniz Pop. A latter-day Stig Anderson, Volle developed his ear for hits by working as a DJ, honing his sense of what moved people on the dance floor. “His theory was that the song has to be something that people know right away,” Max Martin told Time in 2001.

Volle also presided over the creation of an early, all-important pipeline between American starmakers and Swedish producer-songwriters. In the mid-1990s, the great American art of teen pop was being reinvented in Central Florida. The Backstreet Boys, ’N Sync, Britney Spears: All these acts came out of Orlando, through various connections to Walt Disney World and the manager Lou Pearlman. But their hit singles came out of Cheiron. The days when “I Want It That Way” and “...Baby One More Time” dominated the American charts marked the onset of what became known as the Swedish “music miracle.”

Volle died in 1998 of stomach cancer at the young age of 35, just as the American acts coming out of Cheiron were climbing the charts. And with that, Martin, a glam-metal musician and self-described “Iron Maiden junkie” before learning the producer’s craft from Volle, became the face of the Swedish music miracle.

His switch from metalhead to lord of the dancepop may seem unlikely, but it’s not atypical: Sweden, like its neighbors Norway and Finland, has a vibrant metal scene. “Many producers and songwriters of the ’90s had a background in heavy metal,” Helgesson says, adding that metal and pop, for all their differences, place a similar premium on virtuosity. Martin himself mentored a young metal musician—Karl Johan Schuster, now professionally known as Shellback—who has gone on to work on songs for Pink, Kesha, Usher, Avril Lavigne, Britney Spears, Pitbull, Taylor Swift, One Direction, Maroon 5, and Christina Aguilera.

IN RECENT YEARS, SWEDEN has been an early adopter in one other respect as well. Thanks in no small part to its modernist social-welfare state, Sweden was the first European country to adopt a national broadband policy, and is seen as a continental model for rural broadband penetration. Thanks to companies like Spotify, it also has the highest percentage of digital music revenues from streaming as opposed to downloading—91 percent in 2012, almost 10 times the worldwide average.

On the surface, at least, the digital age would seem to present a challenge as much as an opportunity to the Swedish music-industry cluster. The most active frontier of pop right now is electronic dance music, or EDM, and its stars are globetrotting DJs who can make beats far from physical studios, on flights from one club gig to the next. By contrast, Stig Anderson and Dag Volle established their careers in an era when producing an album required expensive equipment, layers of personnel, and technical skill—an industrially centralized set of functions.

But Sweden’s comparative advantage in pop music has never just been about infrastructure. Swedish artists—including the young DJ Avicii and the recently disbanded Swedish House Mafia—have been as central to EDM as Swedish producers are to mainstream pop. Which just goes to show that, even in an era when musicians can go anywhere, they tend to go where ideas and connections are. Indeed, the Swedish cluster’s social networks may be growing tighter and more intimate than ever. The production of a typical American pop single often involves trips between big studios in L.A. and Sweden. The production of EDM may be place-agnostic, but as Ola Johansson, the geographer, observes: “It’s not really happening anywhere but Stockholm.”

This post originally appeared in the March/April 2014 issue of Pacific Standard as “Swedish Pop Mafia.” For more, subscribe to our print magazine.