After a few weeks in the studio, Ms. Stefani returned to her other job on “The Voice,” burdened with knowing her marital issues had not yet become public. “I’m not a secret girl,” she explained. “I tell everybody when my period is coming.”

But she soon learned that Mr. Shelton, whom she refers to as “one of my co-workers,” was also in the throes of a personal crisis. He “had been going through literally the exact same thing in literally the exact same time frame,” she said. Her friendship with him blossomed.

Her collaborators noticed a change instantly. “We had anger, we had sadness, we had flirtation, we had sexy, and now we’re madly in love,” Mr. Tranter said. Ms. Stefani described the shift with one of her frequently used terms — “crazy!” — and added, “Never in my wildest, craziest dreams would I ever have seen this coming.”

Ms. Stefani, who sometimes reminds herself “Wow, I did do that! I wrote those songs!” to boost her own confidence, said singing about being happy is “so fresh” to her. “I needed something new to happen. And not just in my career, in my life. Something had to change.

“I’m not going to say I’m not still picking up the pieces and every day isn’t a challenge,” she said. “I’m still in shock. But it’s an awesome time.”