Inspiration and talent play a big part in any successful songwriting venture. But so, too, does luck, and being in the right place at the right time. Just ask Stephan Moccio.

The man who co-wrote “Wrecking Ball,” one of the biggest songs of 2013, might never have had a hand in composing the Miley Cyrus smash if he hadn’t kept an appointment in Los Angeles.

It was September 2012 and Moccio had been spending half of his time on the West Coast for work, leaving his wife and two young children behind in Toronto. Although he was extremely busy in L.A., he accepted an invitation to perform for the Canadian Olympic athletes in Toronto. Tempted though he was to stay at home with his wife and kids, and rest after the gig, Moccio flew straight back out West for a previously booked writing session.

“I didn’t know a thing about the other two writers [Sacha Skarbek and Maureen “MoZella” McDonald], but something told me I needed to go back and do it,” recalls Moccio, still amazed at how it all happened. “We met and there was great synergy in the room. MoZella had just cancelled her wedding and was very frail, but wanted to write about her experience. I’ll never forget the look on her face when I first played these chords on the piano. It was such an emotional moment and that melody, which I’d had hanging around, became the chorus. We knew as soon as we’d recorded the demo, with MoZella singing, that it was a special song.”

There were a number of ingredients that made the song special, Moccio continues. “It had the right tempo (60 beats per minute), the right key for a pop ballad (D minor), and the right message for a dark song about toxic love or a relationship gone bad,” he says. “We weren’t trying to write a hit, just the best possible song. We took the time to write a proper verse, pre-chorus and bridge, and to make it emotional and exciting.”

“We knew as soon as we’d recorded the demo that it was a special song.”

Luck came into the picture when MoZella, who knows Cyrus personally, was able to present “Wrecking Ball” to the singer. “Miley instantly fell in love with the song and recorded it a few weeks later with Dr. Luke and Henry Russell Walter, better known as Cirkut, producing. Miley’s vocal performance is staggering, I think. And my piano, which MoZella originally sang to, ended up being the final piano on Miley’s recording.”

“Wrecking Ball,” the second single from Cyrus’ Bangerz album, came out in late August 2013. By that time, Moccio and his wife had decided to move their family to L.A. and landed there a week later – just as news broke that the song was number one globally in digital downloads.

“It was quite an arrival,” he admits. “My friends at Universal Music Publishing said they couldn’t have dreamt up a better script for me.” A controversial video, featuring a nude Cyrus straddling a swinging wrecking ball, attracted 19.3 million views on YouTube in the first 24 hours of its release. That attention helped the song rocket to top the Billboard charts.

The singer’s even more controversial appearance on the MTV Video Awards, behaving in sexually provocative way with Robin Thicke, further boosted “Wrecking Ball” into the pop-music stratosphere. To date, the song has sold more than three million copies in the U.S. alone. At press time, its video had more than 511 million YouTube views. Twitter also extended the reach, as “Wrecking Ball” became the year’s most tweeted song.

Moccio’s life was caught in the song’s jetstream. “Things were suddenly moving at Mach10 speed,” he recalls. “The phone was off the hook crazy, so much so that I had to immediately change my number. I wasn’t doing anything differently. It was just that Miley’s recipe worked; she had brought our song to the world. Now a lot of other artists are looking at my catalogue and want a song by me. And everyone takes my publisher’s calls now.”