If you were hoping music would be an escape outlet this year, you’d be disappointed. With the major exception of Ariana Grande and her luminous optimism, the most prominent artists in music wrote songs in 2018 rife with anxiety, disillusionment and defiance to match the country’s overall atmosphere. It was a year of upheaval and experimentation, with rising newcomers and veterans alike tapping into misery.

One big winner was hip-hop, which pummeled its way to the top of the charts, doubling its presence in the Billboard Top 10 from the year before. While ascendant rappers of previous eras might have celebrated their newfound successes, 2018’s crop — from Juice WRLD to Post Malone to Lil Pump — confronted loneliness, addiction and paranoia.

If you were hoping music would be an escape outlet this year, you’d be disappointed.

Some artists wreaked havoc not through their lyrics but in transgressions against form. Kanye West and Tierra Whack chopped down the album to a few pristine crumbs, while Migos, Drake and Rae Sremmurd stretched theirs toward a streaming-friendly interminability. Both Earl Sweatshirt and Blueface raged against the convention of rapping in time, albeit in very different ways. And a crop of young female rockers (Lucy Dacus, Courtney Barnett, Mitski, Soccer Mommy) shook rock by its collar, injecting guitar-driven music with startling and invigorating new perspectives and melodies.

The artists who created the year’s 10 best albums hail from the Bronx, Houston, Richmond and beyond. While some were manufactured for top of the charts and others are decidedly anti-commercial, they all operate within the larger pop sphere; they possess astonishing, innovative songcraft and display a bent for mischief and exploring contradictions. Here they are.

10. Cardi B, “Invasion of Privacy”

In an era of mercurial public figures, Cardi B stood out for her ebullient, outsized persona and her ability to bottle lighting bolts of energy and fire them off to the world in tweet-sized portions. She’s been delivering quippy one-liners and clapbacks through social media and reality television for years — so in hindsight, it’s not at all surprising that she could so seamlessly convert her verbal gifts into music.

Her debut album, “Invasion of Privacy,” is stacked with these moments, each of which encapsulates her wit, joy and brassy confidence. The line “I gotta stay out of Gucci / I'm finna run out of hangers,” from the album standout “Drip,” made even Kanye West jealous.

9. Colin Self, “Siblings”

Peace and destruction live side by side on the second album by Colin Self, an Oregon-born electronic composer. While songs like “Survival” are Enya-esque in their serene beauty, others are frightening: “Research Sister,” for example, splices together ghostly operatic samples and splintered cymbal crashes, conjuring visceral horror like a sonic Guernica.

The mission of Self — whose work explores queerness and resistance — is not one of chaos but rather community. He comingles synth-pop, political poetry, science-fiction and techno. “Quorum” samples the banter and laughter of a group of women, turning everyday conversation into a conduit of power and solidarity.

8. Kacey Musgraves, “Golden Hour”

No album this year was more aptly titled than “Golden Hour,” which oozes with both the glowing warmth of a Nashville afternoon and the anxiety of impending nightfall. Within big country-pop melodies and sun-soaked guitar strums, Musgraves muses on the fleeting nature of love, capturing both its early effects (“Butterflies) and the agony as it slips away (“Space Cowboy”).

Musgrave’s observational and empathetic powers hit their peak on “Mother,” when she zooms out from love to life itself. She sings about yearning to be with her mother — while her mother yearns for her mother, who has died. It’s a wrenching portrait of three generations of women, delivered in less than 80 seconds.

7. Key! and Kenny Beats, “777”

Kenny Beats was not nominated for the 2019 Grammys for Producer of the Year, but he should have been. The 27-year-old spent the year churning out dozens of beats for Vince Staples, Young Thug, J.I.D, Rico Nasty and many others. He employs the same toolkit and energy that drives mainstream hip-hop, but colors and curdles his beats with distinct timbres and harmonic flourishes.

His most impressive showcase is this collaboration with the Atlanta rapper Key! Kenny’s beats wobble with slightly detuned pianos, tiny flutes and stuttering bass drums, providing the perfect foundation for Key! to insert his peculiar brand of jovial enthusiasm. (“Love on ice / Kristi Yamaguchi / Your love got me goofy” is one of the silliest and most addictive choruses this year.) The project has a shaggy, unkempt charm; it’s perfect for workouts or pre-games, or just for bopping along to in your car.

6. Earl Sweatshirt, “Some Rap Songs”

Good luck trying to sing along with Earl Sweatshirt on his fourth album, “Some Rap Songs.” He mutters his dense, tongue-twisting lyrics barely above a whisper, veering in and out of time, his voice obscured by flickering soul samples.

This purposeful alienation is transfixing. The 22-year-old Odd Future member has long rapped about his anxiety and depression, and “Some Rap Songs” shows him at his most opaque and hermetic: He muses on stagnation, the weight of expectations and his conflicted feelings about his father — who died this year. “ “I've been spending more money than I'm making / Stuck in Trump Land, watching subtlety decaying,” he raps on “Veins.”

And while you could spend days unpacking his assonance-flashing lyricism, the album is equally astonishing if you tune out the words and simply listen to his flow over the vintage soul loops, which are pulled from the quiet storm era of R&B and spliced in strange, disconcerting ways. There’s no record this year that sounds remotely similar.

5. Beach House, “7”

The Baltimore dream pop band Beach House has become so synonymous with hazy bliss that the Chainsmokers, in pursuit of #chillvibes, named both a song and an upcoming album after them.

But Beach House is about so much more than a vague sense of cool. Their seventh album is their strongest body of work to date: masterfully written and engineered, with thrilling sonic surprises that cannon ball into pools of rapturous synthetic placidity.

Modern pop culture’s churn of fame rewards stars with explosive talent and pays less attention to consistency. It’s been remarkable to watch Beach House’s gradual growth over the last decade, as they cement their place as one of the great American rock bands in recent memory.

4. Mitski, “Be The Cowboy”

Kanye may have gotten more attention for his seven-song albums, but it was the indie singer-songwriter Mitski who launched a much more convincing and lacerating campaign against bloat. Eleven of the 14 songs on “Be the Cowboy” clock in at under two-and-a-half minutes. Some even cut off in the middle of phrases.

This radical concision is fitting for a work that explores longing and transience. Mitski creates half-finished worlds, staging and breaking up marriages, drowning mutely, doing laundry. And beneath the charming and often upbeat musical settings, a barely concealed rage simmers. After listening to the danceable, existential freakout “Nobody,” you’ll never hear disco the same way again.

3. Drake, “Scorpion”

Drake is wrapping up one of the most dominant calendar years in pop history: four Billboard No. 1 hits, countless streaming records, dozens of pristine guest verses and one unavoidable dance craze.

His year’s centerpiece is “Scorpion,” the first masterwork of the streaming era. Clocking in at an hour-and-a-half — triple the length of “Be the Cowboy” — “Scorpion” is an exhaustive a la carte menu with options galore for every mood. There’s defiance (“Mob Ties”), uplift (“Nice For What”), sensuality (“After Dark”) and misery (“Jaded”). There are not one, but three songs of the summer contenders: “God’s Plan,” “Nice For What” and “In My Feelings” (one of them is probably stuck in your head right now). You can listen to “Scorpion” however you want — but please don’t jump out of a moving car to do so.

2. Travis Scott, “Astroworld”

“Astroworld” is a drug-fueled, cameo-stuffed fun house that perfectly embodies 2018 rap in all of its weirdness and anxiety. Scott delves deep into his psyche, recounting a bad trip on “Stargazing” and peeking through the curtains at his foes on “5% Tint.”

He’s much looser when sharing the spotlight with his parade of famous friends, who he pushes into increasingly strange and spellbinding territories. He lets Stevie Wonder and John Mayer run wild on harmonica and guitar, respectively; he gleefully trades bars with his inheritor Gunna on “Yosemite” and even has the audacity to cut off Drake mid-rhyme on one of the year’s very best songs, “Sicko Mode.”

These guests often overshadow Scott himself. But Scott half-admits this on “Sicko Mode:” “Who put this sh*t together — I’m the glue!” he yelps. He’s the creative force that binds together the best hip-hop album of the year.

1. Lucy Dacus, “Historian”

The singer-songwriter Lucy Dacus proudly embraces an everywoman persona throughout her second album, “Historian.” On “Timefighter,” she reduces herself to the mean with a shrug: “I’m just good as anybody / I’m just as bad as anybody.” The screaming guitars tell a different story.

Dacus is one of the foremost talents working in rock music today. She is a bracing lyricist who weaves together startling turns of phrase; an expert arranger who gradually builds her songs to maximize their emotional punch. Her best songs, like “Night Shift” and “Timefighter,” sprawl past five-and-a-half minutes. Just when you think they’ve hit their dramatic and sonic peak, Dacus climbs another level.

And while many other albums this year lack cohesion, “Historian” is a complete package, with earworm singles and blazing extended epics tied together by amusing asides. It starts tiny, with the discomfort of a bungled kiss, and builds momentum until reaching the commanding capstone, “Pillar of Truth,” which unflinchingly surveys the generations of women who endured before her and will after. The song, like the album, is an ode to resilience and quotidian struggle — it may initially seem small and plain, but reveals its brilliance with time.