Before her videos were racking up millions of views on YouTube, the artist spent more than a decade training in one of the world’s oldest and most complex musical art forms.

One Wednesday in July, 40,000 people gathered on a synthetic-grass field on the outskirts of Madrid to watch Rosalía headline the Mad Cool festival’s “welcome party.” For the next three days, 103 acts — including Bon Iver, Iggy Pop and Prophets of Rage — would appear at the festival grounds, which were ornamented by a towering white Ferris wheel. Wednesday, however, was for Rosalía, Spain’s greatest pop export since Julio Iglesias. For her, Mad Cool was a quick stop in the middle of a nine-month tour through Latin America, Europe and North America. But as she took the stage in white platform sneakers and an aqua top with an enormous ruffle running over her arms and chest, she gushed in Spanish, “I am so, so, so thrilled to be here!”

Giant digital screens hung on either side of the stage, projecting her face to the crowd. Less visible was the garter-belt tattoo peeking out below her tiny, high-waisted shorts: a replica of the one that the Austrian feminist performance artist Valie Export gave herself onstage in 1970. Counterpointing sexiness with a kind of SoulCycle strength, Rosalía’s troupe of female dancers wore white bike shorts and hoop earrings. They finished “Como Ali” — an unreleased tribute to Muhammad Ali — with a series of long, rapid-fire air punches, then held their hands overhead in fists.

On one side of the stage stood two male percussionists — experts in performing palmas, traditional flamenco hand claps. Palmas formed the backbone of Rosalía’s next number, “Pienso en Tu Mirá” (“Thinking of Your Gaze”), a deceptively sweet-sounding tune about jealousy that mixes voices, palmas and electronic samples in a shifting 12/8, 10/8 beat pattern. The song, a Pitchfork critic wrote, “stands out from virtually everything else on the global pop landscape.” It appears on Rosalía’s 2018 CD, “El Mal Querer” (“Bad Love”), a.k.a. “E.M.Q.,” which earned raves all over Europe and the United States as one of the best albums of last year. The album’s first track, “Malamente” (“Badly”), streamed 15 million times in its first week in May 2018 and went platinum on the United States Latin charts earlier this year. “Malamente” also earned Rosalía two Latin Grammys and five total nominations, making her the most-nominated female artist in 2018. Last month, with the rest of “E.M.Q.” finally eligible, she repeated the feat, picking up five more Latin Grammy nominations, including Album of the Year. (This year’s winners will be announced next month.)

“E.M.Q.” transformed Rosalía’s life, turning her into a sought-after collaborator who has recorded songs with James Blake, A. Chal, Ozuna and Pharrell Williams. In March, she posted “Con Altura” (“High Class”), a reggaeton collaboration with J. Balvin, on YouTube. It now has more than 951 million views, crushing Billie Ellish’s “Bad Guy” (567 million views), Ariana Grande’s “thank u, next” (432 million) and Taylor Swift’s “You Need to Calm Down” (145 million). When “Con Altura” took the MTV Video Music Award for Best Latin in August, J. Balvin bowed toward Rosalía several times onstage, a gentleman’s acknowledgment of her role in composing the hit. “I think she’s the only artist who can be compared to Beyoncé in the Latin world,” Juanes, the Colombian rock star who has won two Grammys and 23 Latin Grammys, told me. This month she appears in the opening scene of Pedro Almodóvar’s new film “Dolor y Gloria” (“Pain and Glory”), cast opposite Penélope Cruz.

Success like this inevitably provokes backlash. In Spain, rumors suggest that Rosalía is a fake created by industry professionals to satisfy market trends. Spanish Romani Gypsies have attacked her for using words of caló (Romani dialect) in her lyrics and for adopting Andalusian pronunciations and street styles in her videos. Catalan nationalists have complained that she should be using her platform to win support for their independence movement. In the United States, she has been accused of “Latinx appropriation” by critics on Twitter who argue that as a European country, Spain should be excluded from winning Best Latin awards. But if you love music, Rosalía’s groundbreaking compositions and otherworldly voice are themselves the best answers to these sociocultural darts. Before she started topping YouTube and Spotify ranks, Rosalía spent more than a decade training in flamenco, one of the world’s oldest, most heartfelt and most complex musical art forms. It is as if a rising mezzo-soprano decided to leave opera and bring coloratura to R&B.

Christopher Anderson/Magnum, for The New York Times

“A song with a cappella or without a cappella?” Rosalía asked the crowd at Mad Cool.

“A cappella!” the field shouted

“I need lots, lots, lots, lots of silence, O.K.?”

The field hushed. Everyone onstage went silent. As Rosalía poured out the flamenco classic “Catalina,” people wiped away tears. Her voice is both raw and liquid, vaulting smoothly from aching tenderness to angry longing. When she performs pure flamenco, Rosalía often sounds as if she’s pulling her heart out through her mouth. Duende — the ability to transmit deep, authentic emotion — is a moment of nearly mystical self-effacement in flamenco, akin to an actor’s disappearance inside a role. Its emotional vulnerability cannot be faked. Whenever she performs, Rosalía told me, she always tries to find that moment when “you’re not there as an artist, not there as a person with your first and last name,” she said. “You’re nothing more than a channel” for the song’s “soul” to pass through to an audience. “You’re there more than ever, and super awake, but at the same time you’re gone.” She smiled with embarrassment, as if she were sharing a secret.

Two Spaniards, a Canadian, a Colombian and a clip from a Dominican television show came together to make “Con Altura,” an unlikely tribute to reggaeton, and one of the hottest international songs of the summer. By Joe Coscarelli, Alexandra Eaton, Alicia DeSantis, Antonio de Luca, Will Lloyd and Eden Weingart

The day after her Mad Cool performance, I found Rosalía Vila Tobella lounging on a red velvet love seat in her hotel suite, wearing no makeup, her hair twisted into a messy topknot. At 26, she could pass for 19, and much of her style these days seems like an attempt to balance her genetic predisposition to look adorable with expressions of her ferocious drive. The print on her romper was psychedelic flames. She gestured with nails that were long and sharp, polished pink and ornamented with tiny doughnuts, avocados, caramels and kittens.

“I started from zero,” she told me in Spanish. “Nobody in my family is connected to the industry. Not a single contact in the music industry or in the entertainment industry.” Rosalía didn’t want to talk much about her family, whose privacy she says she tries to protect. But she, her parents and her younger sister, Pilar, are close. Her mother, who was an executive at a local company, quit to become Rosalía’s business manager. Pilar, who studied art history, often works as Rosalía’s stylist and creative consultant. Touring for “E.M.Q.,” Rosalía has traveled with them both.

The industry that, indirectly, made Rosalía’s career was car manufacturing. In 1989, S.E.A.T., Spain’s largest auto company, opened a facility on the outskirts of Rosalía’s hometown, Sant Esteve Sesrovires, in Catalonia, in northeast Spain. S.E.A.T.’s move turned a sleepy collection of red-tiled roofs and tree-lined streets — best known as the place where Chupa Chups lollipops were invented — into an industrial hub. Corporations sowed factories and warehouses in the rolling hills surrounding her town, and this crop lured workers from all over Spain. In 30 years, the town’s population quadrupled, to 7,800. Many of these workers came from Andalusia, a region in southern Spain, and many of Rosalía’s friends were their children. At her house, the stereo played Bob Marley, Bruce Springsteen, Bob Dylan and Queen, but her friends listened to flamenco.

The origins of flamenco are not entirely known. The music emerged in Andalusia, which has hosted Arab, Jewish, Romani and Christian cultures for at least 600 years, and the Romani have always been associated with its performance, though flamenco’s guitar style owes much to Catalonia. One day when Rosalía was 13, she was hanging with her friends in a park with some souped-up cars — doors open, songs blasting into the trees — when someone put on Camarón de la Isla, one of the greatest flamenco singers of all time. Listening to him, she told the newspaper El Mundo, “my head exploded.”

In the wake of that blast, Rosalía fixated on learning to sing flamenco. Traditionally, cantaoras absorb flamenco’s complexities through their families, in the same way that other children learn language. For Rosalía, that wasn’t an option. So she took flamenco dance classes and inhaled records by Camarón, who cut several well-regarded albums in the 1970s with the guitarist Paco de Lucía. These albums are pure flamenco: nothing more than singing, guitar and palmas. But in 1979 Camarón broke with de Lucía to make “La Leyenda del Tiempo” (“The Legend of Time”), an album inspired by progressive rock that used an electric bass. In flamenco circles, it was a scandal, like Bob Dylan’s going electric at the Newport Folk Festival. Some people in the press called Camarón the “Gypsy Mick Jagger.” Camarón and de Lucía made up, recording some stunning albums in the 1980s, but the friction between pure flamenco and flamenco fusionists has never really disappeared. In Sant Esteve Sesrovires the winners were Camarón’s fusion offspring; Rosalía saturated herself with their music. And she sang wherever she could: at home, in the streets, at local flamenco performances.

“I’m certain that I will be an artist,” Rosalía declared in 2007 on the Barcelona talent contest “Tú Sí Que Vales” (roughly, “You’re Worth It”), when she was only 15. She took the stage in spike-heeled boots, tight jeans and a tank top. Playing an acoustic guitar, with a medallion of the Virgin Mary dangling from her neck, she sang “Como en un Mar Eterno,” a nasal ballad by the flamenco fusionist Hanna. The judges looked bored. One of them demanded that Rosalía display “some character.” In response, she belted out “No One,” by Alicia Keys. That was enough to pass her on to the finals, where she bombed. “Rosalía, you were regularly off-key during the song,” a judge pointed out. “I can’t do everything,” she responded defensively. “I’m trying to perform, sing and dance.”

Rosalía told me that she auditioned for “Tú Sí Que Vales” because it was the only way she saw to break into show business. Failure revised her ambitions. After that she wanted, above all, to become a great musician. She gave up dancing and got serious about learning piano. She started composing music, with melodies, harmonies, chords and lyrics, trying to teach herself song structure. “I wanted to have absolute control over my music,” she told me, “from the chords and the voicings of the songs to the arrangements and the production.”

There was just one problem: her voice. All those years of faking a cantaora’s power without proper training had damaged her vocal cords. She could no longer project normally. Doctors recommended surgery. After that, she needed a year of vocal rehabilitation. “There’s something I’m supposed to learn from this: What is it?” Rosalía recalls thinking during rehab.

Rosalía believes that nothing happens by chance. “I don’t force things,” she told me. “I can have a wish, and then I let God lead me on the path, bringing me what I need — and always trying to be alert to receive it.” As she recovered in silence, she learned to appreciate the discipline of vocal technique. And she realized that there was someone who could train her to become a cantaora. He taught at Barcelona’s premier music school, La Escola Superior de Música de Catalunya (ESMUC), which usually accepts only one university student a year to study flamenco singing. But it just so happened that when Rosalía needed him most, that professor, José Miguel Vizcaya, was also taking students at another Barcelona music school, the Taller de Músics, where teenagers could enroll.

The day Rosalía first appeared before Vizcaya with a doctor’s report in her hand, he ran through his standard series of questions. What do you like about flamenco? How much flamenco have you listened to? Does your family sing flamenco? What types of music do you sing now? Then he tested her. Sing me some flamenco. Sing me some jazz. Sing me some pop. In this way, Vizcaya assembles a “diagnostic profile” of his students, so he can decide how he’ll train them. He soon figured out that Rosalía was an absolute amateur: The only thing she knew about pure flamenco was Camarón. “I didn’t know anything,” she agreed. “And he taught me everything, everything, everything.”

Vizcaya, who performs under the name El Chiqui de la Línea and is called Chiqui by everyone, has gray hair, kind eyes and a serious, patient manner. He was born in 1951 in Cádiz, the same part of Andalusia where Camarón was born in 1950. His father sang flamenco at bars and parties; Chiqui himself began singing at flamenco clubs when he was 19. A brilliant cantaor, he signed a contract with Los Tarantos, one of Barcelona’s oldest flamenco venues, in the 1970s. There, at the height of the tourist season, he sang four performances a day. After he accepted an offer to teach at ESMUC in 2002, he pioneered a way of translating flamenco’s tradition of private mentorship to a university setting.

Working with Chiqui, Rosalía stretched the range of her voice, learning to project while maintaining its flexibility and clarity. “I sang with fear after my operation,” Rosalía said. “I didn’t want to damage my cords again. And I had to sort of relearn to sing.” With Chiqui, she also learned to improvise melismas, the singing of multiple notes over a single syllable of lyric text. The song “Nos Quedamos Solitos” (“We’re Left All Alone”), which Rosalía recorded for her first album, shows how this works. The lyrics are just a few sentences, roughly: “It was 2 in the morning/my brother came to wake me/why don’t you wake, little brother?/Our mother has died/and we’re left all alone.” Rosalía draws out these words over several minutes with melismas, making you feel the suspense of the events: the waking, the older brother’s voice, the death, the abandonment. Melismas also transform her singing into an embroidered sob that makes you feel the children’s sorrow. Almost every time I listen to it, it brings me to tears.

Melismas are not notated on sheet music. To study them, cantaoras must train their ears. Chiqui taught Rosalía to dissect them note by note so she could replicate the recorded songs that he gave her to practice. “You have to learn what’s happening, one by one, until you know how to execute,” she said. That’s part of the reason becoming a good cantaora takes years. Flamenco melodies can switch from the modern major scale, common in Western music, to the Phrygian scale, common in Arabic and Klezmer music, in a phrase. Rosalía couldn’t read these shifts in the songs she studied. She needed to hear them.

Rosalía may have known nothing when Chiqui met her, but he told me that she had a “perfect ear,” a prodigious memory and an exceptional work ethic. Songs that would take an average student nearly a month to learn, she would master in a week. “She drives me crazy,” Chiqui said. “In classes when she sang the things that I assigned her and she interpreted them” — he reached forward and mimed pinching both her cheeks with pleasure — “I couldn’t stand how well she did it. She was tremendous.” The admiration was mutual. When Chiqui stopped teaching at Taller de Músics, Rosalía applied to ESMUC so that she could follow him there. For a while, Chiqui told me, Rosalía considered recording a pure flamenco album in homage to one of her favorite cantaoras, Pastora Pavón Cruz, a.k.a. La Niña de los Peines (the girl with the combs). In the end, however, she dropped that idea in favor of recording an experimental flamenco album with a guitarist who once performed in a punk-rock band. Rosalía didn’t have just discipline, taste and ambition; like all great artists, she also had an appetite for risk.

“In ‘Los Ángeles’ you can find traditional lyrics, traditional melodies from flamenco,” Rosalía said, gesturing with her doughnut-avocado nails as she described her first album. What isn’t traditional, she said, “is the way in which it’s performed, both in the singing and the guitar and above all in the production.” The CD, which Rosalía released when she was 24, sprouted from her friendship with Raül Fernandez Miró, a classically trained pianist 16 years her senior who performs under the name Raül Refree. In the 1990s, Refree ditched music school to form a punk band, then went on to become an important producer and musician in Barcelona. The first time they met, in 2015, they talked not only flamenco but also James Blake, Kanye West and Frank Ocean. After that, they met in his studio several times a month, sharing music in long listening sessions. “It was like a festival of eclecticism,” Refree told me. She might play him a reggaeton video. He might respond with a clip of American folk. Then they might listen to some pure flamenco or some Glenn Gould. They never talked about recording together. But one day that fall, Rosalía began singing Bonnie “Prince” Billy’s “I See a Darkness.” Refree, who had introduced her to the ballad, sat down at his piano to accompany her.

A few weeks later, she suggested they perform a flamenco show at a bar in Barcelona in front of an audience of about 20 people. Though he had produced flamenco albums, Refree had never played flamenco live. But that night he improvised a flamenco-inspired response on guitar to Rosalía’s melismas. For both, the set felt astonishing. “We could leap into the void and catch each other,” Refree recalled. Rosalía said: “For me it was, like, cathartic. Every time I sang I connected very viscerally, you know?” Walking together afterward, they decided that they had an obligation to make an album.

“I started from zero,” Rosalía said. Christopher Anderson/Magnum, for The New York Times

The songs Rosalía picked for “Los Ángeles” dated mostly to the 1940s and 1950s, the era when La Niña de los Peines was at her height. Ever since the 1970s, flamenco aficionados have favored rough, husky afillá voices, which many people associate with duende. But for this album, Rosalía and Refree both preferred laína voices: clean, high voices, ideal for executing elaborate vocal arabesques. This style suits Rosalía’s own voice, and Chiqui, with his big data set of flamenco memories, spent years helping her explore it. Many of the recordings Rosalía took to Refree’s studio were old and scratchy, time capsules from another age. Together they improvised new versions of each one. “What we wanted was to find a personal reading of that song,” Refree said.

Even then Rosalía knew that she wanted to combine flamenco with electronic music. During the years she trained with Chiqui, she performed nonstop in and around Barcelona. She sang in so many tablaos, jazz bars and hip-hop jam sessions that she couldn’t remember them all. She sang at weddings, private parties and restaurants. She performed in a film festival in Panama and an avant-garde theatrical production in Singapore. She appeared on two dance hall tracks by her friend C. Tangana and on hip-hop tracks by DJ Swet and Cálido Lehamo. She joined a baroque chorus at ESMUC. And, to earn a living, she sometimes recorded music for commercials. With Refree, she even tried out a few songs that she had composed but decided to kept them off “Los Ángeles.”

She deployed all this experience when she wrapped recording on “Los Ángeles” and began devising the senior thesis that eventually turned into “El Mal Querer.” Her first thought was simply to find a way to draw melismas over danceable beats, so she could do more than sit in a chair, the way cantaoras traditionally perform. On the recommendation of a friend, she read “Flamenca,” an anonymous lyric poem from the 13th century that has nothing to do with flamenco. She threw out most of the poem’s love-triangle plot and all of its aristocratic fawning. She kept its vision of a toxic marriage: a man whose insecurity leads him to lock up his wife. She blurred the gender-based roles and read up on the psychology of jealousy. She gave the songs she composed secondary titles like “Chapter 2: Wedding” and “Chapter 4: Fight” to suggest a narrative. Her lyrics read like a feminist version of “Carmen,” a bad romance told mostly from a female point of view. When “Los Ángeles” earned her a Latin Grammy nomination for Best New Artist in 2017, she had already performed early versions of “El Mal Querer” at ESMUC.

Rolf Bäcker, a musicologist and professor at ESMUC who has studied flamenco, told me a funny story about a Portuguese jazz expert who once decided to check out some flamenco in Seville. The expert came out of the tablao crying: He couldn’t understand the rhythms. Each flamenco song style, or palo, is associated not only with a particular kind of melody and harmony but also with a specific metrical pattern. Many palos have shifting beat accents, known as amalgamated rhythms, which can sound like fused meters: a 3/4, for example, meshed with a 2/4. “It’s super hard for someone who doesn’t come from listening to amalgamated rhythms,” Rosalía told me on the velvet love seat in her hotel.

I asked her to show me how it was done.

She leaned forward on the couch, curving her body over her hands to teach me a fast palo called bulería. The moment she began striking her palms together, something flicked on: an intensity and also a playfulness. The beat was in her hands, her right foot, her shoulders, her throat. She clicked syncopations with her tongue and growled Mae West-like “ums” on each beat. “Think in like 6/8,” she said, clapping quickly, “and the bulería is here: One, two, three. Four, five, six.”

I tried to clap and count along, but soon messed up.

“Think in six claps.” She got me clapping six fast monotonous beats. “And now, we’ll give it accent. One, two, three. Four, five, six.” I fumbled along, like a toddler chasing after an adult. Later, when I practiced alone, I saw that the rhythm feels like a driving waltz, at once elegant and aggressive. But, really, Rosalía had taken pity on me. In many of her songs, the pattern is harder. “Pienso en Tu Mirá,” for example, uses an amalgamated 12/8. It took her years, she said, to feel comfortable singing in this kind of rhythm. “It’s not something immediate. It’s something that each time you feel that the more that you know, the more you realize that you need to keep studying and learning, because there are details. The ones who know most are the older people. Grandparents are the ones who sing bulería best.”

Pablo Díaz-Reixa, known as El Guincho, knew nothing about amalgamated rhythms or Phrygian scales or melismas before he collaborated with Rosalía. An electronic musician and producer who once worked with Björk, El Guincho disappeared from the music scene for three years to care for his mother, who eventually died of cancer. But in early 2016, he resurfaced with a dense, brilliant album called “HiperAsia,” which showcased his skill with sampling and vocal production. A few months after it appeared, Rosalía invited him to watch her perform a pure flamenco concert. By then, she already knew that she wanted “E.M.Q.” to be what she called a “voice-centric” project that sampled different voices and played with vocal harmonies.

She later invited him to help her record a song for “E.M.Q.,” “A Ningún Hombre.” Their chemistry in the studio felt natural, Rosalía told me. “I’ve worked with other guys and the way Pablo is is very special, because Pablo really listens a lot,” Rosalía said. “He embraces the fact that I make a lot of decisions.” They spent the next year and half making “E.M.Q.,” meeting nearly every day to work at his place on laptops, a sound card, a microphone and a keyboard. If she taught him flamenco, El Guincho taught her about song structure and helped refine her lyrics. By the time they cut their final two songs — “Malamente” and “Pienso en Tu Mirá” — they were working hand in hand on every aspect of the composition and production.

To my ears, “E.M.Q.” sounds like an album about escaping domestic abuse. There are sounds that suggest beating, weeping, knifing. When I mentioned this to Rosalía, she smiled: “That’s an interpretation.” She kept the lyrics ambiguous, so that different people could hear different plots as they listened to the songs. One of the hardest for her to write was “De Aquí No Sales” (“You’re Not Getting Out of Here”), which required her to find a way to speak truthfully from a place full of rage:

With the back of my hand

I make it clear to you.

I sell you bitter sorrows.

Caramels I can also do.

These lines, even in translation, distill the seesaw of abuse. They also allude to the cantaor Macandé, a peddler whose melisma-filled sales cries for caramels were once a sensation in Cadíz. In “Malamente” and elsewhere she inserted other Easter eggs, a few words of caló that would later enrage some Romani. Rosalía never intended to appropriate Gypsy culture, she told me. For her, the words were simply “a wink honoring that flamenco tradition where caló is present and the Gypsy community has contributed so much.”

“You’re not there as an artist, not there as a person with your first and last name,” Rosalía said. “You’re nothing more than a channel” for the song’s “soul” to pass through to an audience. Christopher Anderson/Magnum, for The New York Times

Rosalía loved working with El Guincho, but there were times while they made “E.M.Q.” that she felt nervous, even anguished. She was in debt, taking on serious artistic and financial risks. What if her experiments mixing flamenco with urban music didn’t pay off? What if nobody would bet on her? She wasn’t signed with a record label. Independence let her make “E.M.Q.” exactly how she wanted. It also meant she had no guarantee that her music would ever see proper distribution. Then she met Juanes.

In September 2017, the Colombian superstar Juanes saw Rosalía sing pure flamenco at a theater in Madrid. Looking every inch the cantaora, she appeared before an audience of about 100 people wearing a long velvet dress and sitting in a chair next to the Romani guitarist Joselito Acedo. “And this woman started singing,” Juanes told me. “I wanted to die. I mean, I had never felt something so strong with someone singing in front of me like what I felt that day, and on top of everything else she was such a young woman, you know? For me it was like seeing Carlos Gardel or Edith Piaf or someone like that sing.”

The first thing Juanes did after leaving the theater was call his business partner, Rebeca León, a former vice president of Latin talent at AEG Live/Goldenvoice. “Rebeca,” he says he told her, “please, you have to take a train to Barcelona. You have to talk with Rosalía. You have to talk with this girl.” Earlier that year, Juanes and León had started the Latin entertainment company Lionfish. The company’s strategy, León told Vanity Fair España last year, is to find artists who “are bilingual, bicultural and who can easily turn into global phenomena.” Their clients have included the Colombian music producer Sky Rompiendo, the Dominican-American trap artist Fuego and the Colombian reggaeton superstar J. Balvin. In Barcelona, León found Rosalía finishing “El Mal Querer.” In January 2018, León joined Rosalía’s team as the artist’s manager.

But even León had trouble finding a home for “E.M.Q.” “In the beginning many people didn’t understand,” León told Variety. “They said it was too left of center, you’re gonna have to spend too much money, it’s never gonna work.” In cases like these, YouTube videos have become a lifeline for Spanish-speaking artists. A decade ago, they needed to sing in English to win corporate support and penetrate international markets. “What YouTube has done is opened up both genres and different-language music,” Vivien Lewit, YouTube’s global head of artist relations told me. “The music itself is connecting with the audience, and the language itself seems to be in a place where it’s almost secondary.” Latin artists now make up more than 30 percent of YouTube’s billion-views club, and so far this year, five of YouTube’s Top 10 most-viewed artists are Latin: J. Balvin, Anuel AA, Ozuna, Bad Bunny and Daddy Yankee. Numbers like these can convince record-label executives that international artists are worth signing.

For the videos that she needed to make “E.M.Q.” feel accessible, Rosalía turned to her friends at Canada, a Barcelona company that shoots multinational advertisements and music videos. In their productions for “Malamente” and “Pienso en Tu Mirá,” the director Nicolás Méndez stirred together Spanish icons and urban signifiers: olives and big-rig trucks, bullfighters and track pants. In one shot, a hooded Catholic penitent on a skateboard does an ollie in front of a huge cross. Setting Rosalía’s music in industrial parks like the ones surrounding her hometown, Méndez revealed its potential to express a new vision of Spanish identity, one that is profoundly traditional and yet urban.

“Malamente” now has more than 107 million views on YouTube. “Pienso en Tu Mirá” has crossed 50 million. Weeks after they went live, Rosalía signed a contract with Sony Spain. Suddenly “E.M.Q.,” an album made by two friends holed up in an apartment, didn’t look so left of center, and Rosalía had secured the backing she needed to promote it all over the world.

This summer, at the MTV music awards, Rosalía took the stage in a crystal-trimmed bustier and black platform boots and performed the closest thing that she has written to a straight love song: “Yo x Ti, Tu x Mí” (“Me x You, You x Me”), a collaboration with El Guincho and the Puerto Rican trap and reggaeton sensation Ozuna. Rosalía sang it onstage shortly after Camila Cabello and Shawn Mendes did their love song “Señorita.” The contrast was impressive. There was Cabello in heels and a transparent dress rubbing against Mendes like a cat. And then there was Rosalía mixing flamenco gestures with modern and African dance and hip-hop. Onstage, she was fierce: Ozuna’s equal, not his pet.

Dancing was the first thing that Rosalía gave up when she decided to become a serious musician. And it was the last element she needed to transform herself into a global pop sensation. She could have simply twerked and stripped, turning herself into a moving centerfold as so many female artists do. Instead she messaged Charm La’Donna, the choreographer behind Kendrick Lamar’s dramatic and militaristic Grammy performance in 2018. Rosalía didn’t want her dances to suggest submission. “There’s always an intention to show the figure of the woman with strength and power,” she said. With La’Donna, who has choreographed most of Rosalía’s videos and live performances, she hatched a dance style that blended flamenco’s sinuous gestures with hip-hop’s punch.

It’s still too early to know how Rosalía’s career will evolve. “When you’re in a relationship, there’s all kinds of moments,” she said, imagining her future as a musician. “The beginning tends to be one way, the middle tends to be another and the ending tends to be another.” She smiled. “So I know I’m going to pass through all that. I know that I will age making music, and I want to see how my music changes with the years.” What she wants most is “never to lose the desire to keep making music.”

Last February, standing onstage in a floor-length red dress at the Goya Awards, Spain’s version of the Oscars, Rosalía sang, in Spanish, “Me Quedo Contigo” (“I Stay With You”), by Los Chunguitos:

If you make me choose

Between you and glory

So that history speaks of me

For centuries, oh, love ...

I stay with you.

In her arrangement, Rosalía replaced the electric guitar and the drums with backup singing by the youth chorus Cor Jove de l’Orfeó Català. The change brought forward the song’s subtext, making it a declaration not just of romantic love but also of spiritual devotion. Her voice danced between strength and vulnerability, the knowing sneers and smiles of her pop performances were wiped from her face. In the final bars, her eyes glistened; her lower lip trembled. It was beauty. It was innovation. It was duende. Could it also have been a song about a life devoted to music? “You still haven’t seen everything that Rosalía can do singing pure flamenco,” Chiqui told me. “Everything that she is, everything that she has inside, it still hasn’t been seen.”