Oscar-winning actress Mary Steenburgen went under the knife for a routine surgery in 2009. Hours later, she woke up as a different person — and became a great songwriter.

The bizarre odyssey of how Oscar-winning actress Mary Steenburgen came to co-write the euphoric power-ballad that Jessie Buckley performs at the end of “Wild Rose” — easily the year’s best original movie song — began 10 years ago, when the “Melvin and Howard” star woke up after a minor arm surgery feeling like her mind was on fire.

“I felt strange as soon as the anesthesia started to wear off,” Steenburgen said. “The best way I can describe it is that it just felt like my brain was only music, and that everything anybody said to me became musical. All of my thoughts became musical. Every street sign became musical. I couldn’t get my mind into any other mode.”

Fun as that might sound in an Oliver Sacks kind of way — the late neurologist wrote about similar, potentially stroke-inspired symptoms in his book “Musicophilia” — Steenburgen wasn’t thrilled about the sudden mental shift. The next two months were tough. “I couldn’t focus, I couldn’t have acted,” she said. “I couldn’t have learned any lines. My husband [actor Ted Danson] and I were kind of frightened about it.”

Steenburgen’s son, filmmaker Charlie McDowell (“The Discovery,” “The One I Love”), also remembers it as a trying time. “If your mom comes to you after surgery and says that her head is now full of music, I think it’s totally fair to think that she’s gone crazy and has major psychological problems,” he said. “All of a sudden she was referencing these obscure indie bands and picking up random instruments — I’m not gonna lie, the accordion playing drives me nuts,” McDowell laughed. “When I say all this out loud it sounds insane. It was definitely a change.”

Despite the paucity of roles for women in their mid-50s, the actress wasn’t exactly itching to do something else. “I had been somebody who really liked music,” she said, “but I had never been obsessed with it; I was obsessed with acting, and that felt like a big enough subject for me.”

When the music didn’t go away, Steenburgen realized that she had to do something with it — if only for her sanity — even though she didn’t know how to play an instrument. “I called a very talented friend of mine on Martha’s Vineyard and I said: ‘Look, if I come over every day and sing what I hear in my head, could you help me make them into songs?’” she said. She wrote hundreds of songs that summer and sent 12 of the best ones to a music lawyer under her mother’s name. “He wanted to work with ‘Nellie Wall,’ but then I showed up instead,” she said.

The next thing she knew, Steenburgen had been signed to Universal as a songwriter and was on a plane to Nashville. It was the first stride on a strange path that would eventually lead to Tom Harper and Jessie Buckley’s doorstep almost a decade later.

Flash-forward to 2017, when Harper — a young British filmmaker hot off directing a lush BBC adaptation of “War & Peace” — had just found his next project. He’d fallen in love with an electric Nicole Taylor script called “Wild Rose,” a fish-out-of-water story about a self-destructive Glaswegian country singer and single mom whose only dream in life is to sing Patsy Cline ballads at Nashville’s Grand Ole Opry. Buckley — who landed a key role in “War & Peace” after surging to fame on the U.K. singing competition “I’d Do Anything” — had agreed to play Rose-Lynn Harlan, and Harper knew in his bones that she was perfect for the part.

There was just one problem: The climactic song that ties the whole movie together didn’t exist. The script called for a soaring, original anthem that Rose-Lynn belts to a loving hometown crowd in the very last scene after she’s learned to reconcile her dreams with her reality in a way that makes them both feel a little more special, but no details. Phoning in from London, Harper remembered the anxiety of moving forward without that crucial missing piece: “The script just said something along the lines of, ‘Rose-Lynn sings an incredible song and it conveys everything that she wants to express to her mom and kids and everyone’s uplifted. The end,’” Harper said. “I had faith that we could figure it out, but it was really worrying.” Universal’s music division provided some demos, but none of them clicked.

At the last minute, a sample came in called “Glasgow (“No Place Like Home”). “It grabbed me by the heart the moment I heard it,” he said. “It just connected.” Buckley, who phoned in from the Chicago set of “Fargo,” had a similar experience: “It was just that immediate feeling of ‘this is the song.’”

That’s when Harper and Buckley first learned who had written it, and found themselves blindsided by “the Mary Steenburgen of it all.”

﻿

As it turned out, Steenburgen had spent the last few years toiling away on her own dream of making it in Music City. And despite the many advantages that her fame might have afforded her, she was more nervous about going there than Rose-Lynn Harlan has ever been about anything. “It was terrifying,” she said. “The first session I did was a total disaster, and I literally went back to my hotel room in tears, cried my eyes out, and thought ‘Why would anyone be so stupid at age 54 to think they could do something so new?’”

But she also felt like she didn’t have much of a choice. “I was back at it by the next morning,” she said. “I just told myself: ‘I’m going to go right up and sing the bleeping song if it kills me!’” Not long after that, Steenburgen bought a house in Nashville.

McDowell still laughs at the memory of hearing his mom spontaneously begin to scat in the backseat of his car. “It could have been really easy for Mary Steenburgen to just put her name on something and get a pass on many of the usual steps in some new creative thing, but she didn’t do that,” she said. “She put in the time to learn the craft, and I respect that. And I have to admit, she’s gotten really good at the accordion.”

Steenburgen’s career experience also gave her a unique advantage over the competition: While most of the songwriters who submitted demos for “Wild Rose” were content to read a plot synopsis and work in broad strokes from there, Steenburgen approached the assignment as if the song were a character for her to play. “I fought to get the full script, because I just felt like I was looking at such a small part of the story without it,” she said. “Where does Rose-Lynn live? What does her apartment look like? I needed to think of imagery that might be cohesive with what the production designer, the cinematographer, and the composer would be doing; there are all these people you haven’t met yet who are telling the same story. And as soon as I read the whole thing, I understood what we were writing.”

That process led to a realization: “It was a really love song from Rose-Lynn to her mother …It was also a love song to her city and a love song to the concept of home and the fact that home doesn’t have to be second best for her or something that she settles for.”

﻿

Both accomplished songwriters who had previously written music for the television show “Nashville,” Steenburgen’s co-writers Caitlyn Smith and Kate York came to the project with a similar appreciation for the challenge of writing character-driven chords. “It’s a totally different muscle,” York said. “You have to take yourself out of it a little bit — it’s kind of like acting, I guess.” Smith agreed: “It’s a different job altogether. If you’re just writing a song for someone else, it’s wide open and sometimes hard to figure out. And if you’re writing for yourself, you’re really digging into your own heart.” This particular task was a little bit of both. “I feel like we could get into the guts of this song because we’ve all lived a similar crazy dream story,” Smith said.

The first thing they found out is that Rose-Lynn worships Patsy Cline, and so the three writers knew they had to craft something with classic country DNA (not an obvious assumption in a film that builds to a blink-and-you’ll-miss-it cameo from a genre-bending superstar like Kacey Musgraves). Smith seized on something with a 6/8 feel, and they all decided to stay there. But the songwriters also reckoned with the role that Glasgow plays in Rose-Lynn’s life, and not just as an albatross around her neck.

“Anything we wrote had to have a fond hint of Scotland,” Steenburgen said. “So I called one of my best friends, a Scottish woman who started out as a nanny and ended up like a sister,” a detail that dovetails eerily well with the plot of the film. “So I called her up and said ‘Talk to me in your accent — talk to me about you.’ And through that we wound up with images like the opening line: ‘I’ve worn out the stones in front of your doorstep.’”

The entire song went from a dream to a demo in just a few short hours — which, when you listen to “Glasgow,” seems as crazy as the story that led Steenburgen to co-write it. “It may sound shallow or like it’s a factory when I talk about how fast we write these things,” Steenburgen said, “but I always think of it like this: ‘I can’t take days to do a scene.’ I can’t say ‘I don’t know what the emotion is for the character, so can you give me until tomorrow?’ I’m always having to tell stories on a time limit.” Steenburgen has only found one drawback to collaborating with Smith and York: “They’re such good singers that people are going to get intimidated by their demos and go, ‘Well I can’t sing like that, so I’m not doing that song.’”

1996-98 AccuSoft Inc., All right

Buckley, who hadn’t sung in a long time before the production, worried about doing justice to a song like “Glasgow,” especially given that she had no background in country music. “But the story of it really moved me,” she said, “so I sat down with a guitarist in a room and sang it really badly and just tried to attach some emotional feeling to it before we started filming.”

By the time Buckley learned who had written the song, she was only half-surprised: “It made sense, because it clearly came from someone with a complex understanding of character — someone who was able to kind of go right to the root of what this woman’s story is about, and managed to write lyrics that exposed the cracks under the surface,” she said.

While Buckley own story feels something like a fairy tale come true, she drew a distinction with her character. “I told her my secrets and she told me hers and we built a different person together,” she said. “‘Glasgow’ is a song of belonging. It’s about stretching yourself to places that you don’t know are within yourself.” For the first time in a long time, Buckley had something to sing about. “This song was such a gift to me,” she said. In turn, it also became her gift to the women who wrote it.

Steenburgen called Buckley’s performance “stunning,” but seemed changed by the experience in a fundamentally different way than everyone else involved. “Music is in my genes thanks to the women in my family, and I just think I was somehow granted access to it,” she said. “It was so overwhelming for me in the beginning because I didn’t grow up with having that voice in my head, like Kate and Caitlyn did.”

﻿

The barnstormer of a song that Rose-Lynn performs in the film’s last scene conveys the ache and discovery of her journey from prison to paradise. It begins with Buckley’s voice cresting through an ocean of silence, as Rose-Lynn summons the strength to confront her regrets until they resolve into love. She apologizes to her family, her children, and the entire life she tried to escape: “I pushed you away, put a pin in a map, then I got lost in the storm.”

A faint lilt begins to hum behind her, peeking through the lyrics like the first ray of sunshine after a squall: It’s an accordion, lighting Rose-Lynn’s way towards a place she never could have imagined before. “Had to find my own way, make my own mistakes, but you know that I had to go,” she sings. “Ain’t no yellow brick road running through Glasgow, but I found one that’s stronger than stone.”

And then Rose-Lynn hits the chorus with the sweet relief of someone who’s tunneled their way to freedom, as Buckley’s voice swells from low to high and back again. She sings on behalf of anyone who’s ever had to learn about themselves the hard way: “Ain’t no place like home,” she and Rose-Lynn sing together, and as the song becomes so big that it envelopes them both, along with all the Glaswegian extras who packed into Celtic Connections for the 12-hour shoot, and everyone in the audience. It’s staggering.

It’s also not the happy ending that Rose-Lynn imagined for herself. And yet, happiness often looks different from how you saw it in your head. When Steenburgen’s life took an unexpected detour, it felt like fate (or a weird quirk of anatomy) was forcing her to choose between the dream she’d had since she was just a starry-eyed girl in Little Rock, Arkansas, and the strange new reality that had ambushed her in a hospital one night. To hear it from her now, it sounds like she’s found a beautiful harmony between the two.

“I didn’t fall out of love with acting when this happened,” Steenburgen said, “and I still haven’t. But there’s so much more capability in our brains than we probably realize, and agreeing to diminishment and shutting down doors is a choice that we all make for ourselves. It turns out you don’t really have to do that.”

﻿

“Wild Rose” is now available on DVD and VOD.

Sign Up: Stay on top of the latest breaking film and TV news! Sign up for our Email Newsletters here.