It’s been four years, but Lorde fans finally have the green light they’ve been waiting for.

The precociously talented New Zealander is releasing her long-awaited second album, “Melodrama,” on Friday, and will play a tiny show at Bowery Ballroom for SiriusXM the same night. Now 20 years old, the “Royals” star (real name Ella Yelich-O’Connor) has channeled her breakup with photographer James Lowe and the pressures of fame into the new songs. But “Melodrama” was also heavily inspired by New York City, where the singer spent a year recording, writing and soaking up everything the Big Apple has to offer.

Here’s how Lorde made Gotham her own.

Electric Lady Studios

52 W. Eighth St.
Lorde has been posting pictures of herself with producer and co-writer Jack Antonoff (of fun. and Bleachers) at the legendary studio since August. But when one fan rudely questioned why she was taking so long on the second album, Lorde made it clear she wouldn’t be rushed. “I’m an artist. I write a record when I have enough special stories to tell,” she snapped on a since-deleted Instagram comment. “It’s all me, every melody every lyric … I’ve worked like a dog for a year making this thing great for you guys.”

Liquiteria

402 Sixth Ave.
The West Village juice spot was the refreshment pit stop of choice for the singer. One employee (and Lorde superfan), Ayesha Mangu, got a shock last month when she found herself serving her idol just days before Governors Ball. They got on so well that Lorde later personally invited Mangu to see her at the festival on Randalls Island. “I was gonna ask u [sic] in the store if u [sic] wanted to come but I got shy!” said Lorde in her Twitter message to Mangu. Even pop stars get scared, sometimes.

The F train

Most artists stick to thanking their manager, friends and family on their album credits. But Lorde gives the NYC subway system a shout out on “Melodrama.” She used her rides on the F train to write and even record rough melodies, with most straphangers unaware of the Grammy winner in their midst. “On the train, there would be a lot of coming up with an idea and singing it into my phone as quietly as I could, so no one would hear me,” she told “CBS Sunday Morning.” Given that unusual demoing process, it’s a wonder “Melodrama” doesn’t feature a cameo by “showtime” dancers.

The Flame Diner

893 Ninth Ave.
Another place that Lorde found anonymity was the 24-hour “Flame Diner” near Columbus Circle. Popular with elderly locals, the singer again was undisturbed as she worked on music on her laptop. It’s now become a pilgrimage site for Lorde loyalists. “We have many young girls coming in and asking about her because she found this place to be inspiring,” says cashier Maybelline Cedeno. “But I never saw her when she was here — we see too many people to remember who they are!”

Taylor Swift and Lorde popped into Le Poisson Rouge for a show last October.247PAPS.TV / Splash News

Le Poisson Rouge

158 Bleecker St.
She may be an introvert by nature, but Lorde learned a little about letting loose during the last year. She admitted that she was out partying much more than normal — an experience that informed “Melodrama” tracks “Green Light” and “Sober.” In October, she was spotted out with her buddy Taylor Swift (and squad members Cara Delevingne and Suki Waterhouse) at a secret Kings of Leon show at Le Poisson Rouge.

Sam McKinniss’ Brooklyn studio

For the album cover painting, Lorde approached Brooklyn artist Sam McKinniss. The two spent time hanging out in coffee shops around his East Williamsburg studio and found that the singer adored McKinniss’ giant portrait of Prince from the “Purple Rain” movie. “We really got to relate to each other on that and the big impact Prince had on us, and how his death affected us as creative people, and also as fans,” McKinniss told W Magazine.

8 Spruce St.

Lorde posed for McKinniss in November at his friend’s apartment on the 42nd floor of this Frank Gehry-designed residential skyscraper near the Brooklyn Bridge’s Manhattan side. He took photos, which he later used as studies for the painting that became the “Melodrama” cover art.