Back in the nineteenth century, when many of the ballets that we think of as the backbone of the art were being made, there were composers who specialized in writing music for dance. When the French-born, St. Petersburg-based ballet master Marius Petipa needed a mazurka, he would tell a composer employed by the Russian Imperial Theatres to write him one, specifying how many bars of music he would need and whether it should be lively or stately. This system produced music that was perfectly adequate, and sometimes a little better than that.

But then serious composers, like Tchaikovsky, started to take an interest in dance, and, lo and behold, the ballets were better (although Petipa still told Tchaikovsky what to do). This is how we got “The Nutcracker” and “The Sleeping Beauty”—ballets that have survived to this day, and whose music is inseparable from our idea of the dance.

Ever since, choreographers have sought out composers whose music moves them and unleashes their imaginations. If they’re lucky, they find one who is still living and whose artistry suits their temperament just right. George Balanchine had Stravinsky—acerbic, witty, rhythmically exciting. Alexei Ratmansky has Leonid Desyatnikov—playful, at times mysterious, and, like him, a stylistic magpie. And, since 2012, New York City Ballet’s Justin Peck,has been forging an ever-deepening relationship with the singer-songwriter Sufjan Stevens. (In case you didn’t notice, ballet has been dominated by men for centuries.) On January 31st, New York City Ballet will unveil Peck and Stevens’s fifth collaboration to date, which they have called “Principia.” In a month, they will bring another collaboration onto the stage, at Houston Ballet. They are definitely an item.

They don’t just make ballets together—they’re also friends. They take bike rides in Central Park and make dinner and travel together. Stevens recently played a song at Peck’s extremely sweet-looking wedding to a fellow-dancer, Patricia Delgado, on a beach in Miami.

Justin Peck, left, says he considers himself a traditionalist, a “classical-ballet choreographer.” “We like to be conservative together,” Stevens said. Photograph by Erin Baiano

Unlike the other composers mentioned above, Stevens, who is forty-three, doesn’t come from the classical-music world. And that may be one of the reasons Peck was first attracted to his music. Stevens’s albums, such as “Illinois” and “Carrie & Lowell,” often combine the tunefulness of folk music with an indie-rock sensibility; they’re sensitive and sincere. Even his bigger projects, like the multimedia work “The BQE” and the electronics-heavy album “Enjoy Your Rabbit,” are sophisticated but unpretentious and openhearted. They have, as Peck puts it, an “authentic human touch.” The melodies, while not always particularly catchy, get under your skin.

Peck first became aware of Stevens’s music when he heard “Illinois,” in 2005, while he was still a student—a kid, really—at the School of American Ballet. (He was sixteen years old.) He hadn’t even started thinking about making dances then. He’s only thirty-one now, and he began choreographing in his early twenties. Peck was moved not only by Stevens’s melodies but also by his ability to create atmosphere through his eclectic choice of instruments and his use of asymmetrical rhythms—bars with seven counts, or nine, or five. That quality made the music seem interesting, fun to count, and, possibly, good to dance to. He stored it away in his mind.

When Peck started to get the itch to choreograph, he heard Stevens’s music again, this time an adaptation for string quartet of the 2001 album “Enjoy Your Rabbit.” The style was a bit more playful, and the music had more of the jagged rhythms Peck liked. He decided to make a small dance using a section of the score. He wrote Stevens a long and sincere letter, asking for his permission to use the music. Stevens responded curtly. (He was on tour.) He told me, “I said, ‘I don’t know anything about ballet and I don’t care. But go for it.’ ”

That short ballet eventually became a much longer one, “Year of the Rabbit,” which premièred, to much acclaim, in 2012, at New York City Ballet, where Peck is both a dancer and, since 2014, the choreographer-in-residence. For that performance, the score was adapted once again, this time for string orchestra, by the composer and horn player Michael P. Atkinson, a member of the New York-based ensemble the Knights. It was this ballet that put Peck on the map.

Since then, the collaboration between Peck and Stevens has become much closer. Thanks to Peck, Stevens now knows a lot more about ballet, and actually likes it. Interestingly, for a guy who taught himself to play most of the instruments that he uses in his music, and who never received academic training as a composer, he prefers traditional works, performed on pointe, rather than those danced in sneakers or barefoot or in socks. “I like the formality,” he said recently, at Lincoln Center, before a rehearsal of “Principia.” “I like the restriction and the fact that it’s anachronistic and not at all contemporary.” Peck, too, says he considers himself a traditionalist, a “classical-ballet choreographer.” “We like to be conservative together,” Stevens said, flashing a Cheshire Cat-like grin.

Which isn’t quite true. Peck’s ballets do feel classical, in the sense that they have a certain formality and impersonality about them; they’re not gushy or overly emotive. They use a finely tuned ballet vocabulary, and the dancers get to show off their immaculate technique and control. But they also have a youthful, and often inquisitive, feel. They can be a little bit emotionally tentative, displaying the reticence of a young man still figuring out his place in the world. And they often feature ambiguous relationships among the dancers, who pair up and partner with people of either sex, sometimes romantically, sometimes not. That ambiguity and openness feels very contemporary, rooted in the shifting, uncertain social world young people live in today. Peck is very much of his time. And Steven’s music helps him tap into that inner vibration—the sense that the world is a little bit confusing and not always friendly. “For some reason, it pulls ideas from a deep place in me that I don’t necessarily get with other music I work with,” Peck said.

In additional to ballets on pointe, Peck also makes works that are performed in sneakers (a style he adopted from one of his idols, Jerome Robbins) and ballets that include tap-like moves, like his urban-dance influenced “The Times Are Racing,” from 2017. He has an interest in musical theatre, too. Recently, he choreographed the dances for a Broadway revival of “Carousel,” and soon he will do the same for Steven Spielberg’s upcoming adaptation of “West Side Story.” He’s a truly American choreographer. (The only thing he won’t do is choreograph dances performed in socks, a style popular in the contemporary dance world. “I don’t like the way they feel on my feet,” he said, scrunching up his nose. “They move around.”)

But none of this has anything to do with Stevens. With Stevens, he never choreographs in sneakers. “I won’t allow it,” Stevens said, with a sly laugh. “I’m a modernist neo-romantic post-minimalist traditionalist.” In 2014, the two of them made a big, loud, boisterous ballet called “Everywhere We Go.” Then, three years later, Stevens wrote a very quiet series of pieces for solo piano, the result of hours and hours of improvisation at the keyboard, and these became the basis for a spare, elegant, ruthlessly formal ballet called “The Decalogue.” (The New York City Ballet dancer Sara Mearns ruled over this highly ordered, geometrical onstage world with her usual authority. To my mind, it was one of Peck’s finest works.)

The current project, “Principia,” falls somewhere in between these two extremes. “I wanted it to be big and bright and powerful, like ‘Everywhere We Go,’ ” Stevens said, “but less bonkers. Shorter. Tighter. Leaner.” Like “Everywhere,” “Principia” is arranged for a large musical ensemble, with orchestrations by the young composer Timo Andres. The title is a reference to Sir Isaac Newton’s “Philosophiae Naturalis Principia Mathematica,” in which the seventeenth-century physicist and philosopher set out the basic laws of motion: the effect of gravity on objects on Earth, the movements of the planets, the tides, the speed of sound. In other words, he more or less explained the rules behind how everything in the known world is supposed to work. Out of this idea came the inspiration for the stage design: a backdrop, by Karl Jensen, based on a planetarium-like cenotaph that the eighteenth-century French architect Étienne-Louis Boullée designed for Newton, which was never built.