In 2013, Brandon Lancaster was playing shows around Nashville with his band, LANCO. He lived with four people in a two-bedroom house, except when he couldn’t afford the rent and briefly had to move back in with his parents. He wasn’t established enough to book any co-writing sessions with famous Nashville writers, so when he had an idea for a song called “Greatest Love Story,” inspired by his girlfriend, he wrote it himself.

Two years later, LANCO got a record deal. In summer 2017, as the band continued to tour, it opened for country star Sam Hunt at the Minnesota State Fair. Lancaster remembers that show because when the band played “Greatest Love Story,” it sounded like the thousands in the crowd were singing every single word. Although the band had earned an “underground following” playing smaller venues, as Lancaster put it, they were taken aback by the reaction.

“We were looking at each other onstage, like, ‘This isn’t a club somewhere. This is 15,000 people screaming this song,’ ” Lancaster said.

They shouldn’t have been too surprised. “Greatest Love Story,” which just hit No. 1 on country radio for two weeks, has become one of the biggest country hits of the year, recently certified gold for selling 500,000 copies. Its success fueled the just-announced debut album, “Hallelujah Nights,” which will be released in January.

ButGreatest Love Story” was an unexpected hit in some ways, as LANCO — Lancaster, Chandler Baldwin, Eric Steedly, Tripp Howell, Jared Hampton — is well-known in Nashville but far from a household name. Incidentally, that’s one reason the song received an unusual boost.

The band put the song on Spotify long before it was officially released as a single in March, and it caught the attention of Nate Chetty, a writer for Netflix’s rural comedy “The Ranch,” which returns for new episodes Dec. 15. The creative team was looking for a meaningful track that could play during an emotional scene in the ninth episode, in which Colt (Ashton Kutcher) sees his soul mate/ex-girlfriend, Abby (Elisha Cuthbert), get engaged to another man.

“Greatest Love Story” had two things going for it, according to “The Ranch” creator Jim Patterson. First, the lyrics are about an on-again, off-again couple, which describes Colt and Abby’s story. Second, LANCO’s status as a new band made it easier — and cheaper — to license.

“We’ll go out and use a Kenny Chesney song, but those songs are usually more expensive for these established artists,” Patterson said. “So we try to find artists who are up-and-coming so we can feature them, because it helps us financially as well.”

“The Ranch” has become well-known for featuring country music, both mainstream acts and independent artists, and fans create Spotify playlists of their favorite songs from the soundtrack. While the show doesn’t get the same kind of awards attention as Netflix’s other hits, it’s extremely popular, ranking in the Top 5 on Netflix’s most quickly binged shows — higher than “Stranger Things” and “Orange Is the New Black.”

So, as “Greatest Love Story” played over a closing scene of a dejected-looking Kutcher, it played into the end credits as well, which sent fans to their phones to type questions like “What was the song and artist played at the ending credits of The Ranch episode 9?” The episode started streaming when Season 1 debuted in April 2016, and because of Netflix’s binge-watching model, new people can continually discover the show — and by extension, the LANCO song — at any time.

“Lots of people have said that’s where they heard the song the first time,” Lancaster said. “They heard it on that show before it was on the radio.”

“The Ranch” gave the song a boost, but country radio quickly jumped on the midtempo track when it was officially released as a single, which propelled it to the top of the charts. After LANCO made its Grand Ole Opry debut this fall, “Greatest Love Story” rocketed to No. 1 on the iTunes country charts. Lancaster joked they all took screenshots when they noticed their song was higher than Taylor Swift’s “Look What You Made Me Do” on the all-genre chart as well.

Still, Lancaster — who now has the rare distinction of being a solo writer on a contemporary No. 1 country song — can’t really process how much the song has taken off. One explanation is that the song’s theme is simply very relatable. Written about his girlfriend and now wife, it’s about a couple that breaks up but finds the way back to each other.

“It’s a personal story, but when I saw how much the story resonated with the guys in the band, … I thought, ‘Maybe we can play it and people in the crowd would find [themselves] in it,’ ” Lancaster said. “Little did we know how many people would find themselves in that song.”

Read more: