After nearly two years of rumors, “Supergirl” is heading to The CW for its second season, Variety has learned.

The network shuffle cements “Supergirl’s” Season 2 renewal.

The superhero show, starring Melissa Benoist, was at CBS for its first season, which was quite the departure for the older-skewing network. At the time, CBS’s former chief Nina Tassler was looking for a female heroine and greenlit the Greg Berlanti-produced project for the 2015-16 slate. Before “Supergirl” was initially ordered to series, rumors were flying that the show would land at sister net CW, though it was in development at CBS.

At CBS, “Supergirl” averaged a 2.5 rating in adults 18-49 and 10.03 million viewers overall in Nielsen’s “live plus-7” estimates. It was CBS’ top-rated rookie drama this season in the demo, and was also its youngest-skewing drama with a median age of 55.6 — however, it was down from the network’s comedy lineup in the Monday night timeslot last year.

The hotly anticipated crossover with “The Flash” on March 28 provided a ratings boost for both shows, prompting the rumors to begin swirling once again that “Supergirl” would head over to the younger-skewing network in order to nab a renewal. That “Supergirl” episode, co-starring “Flash’s” Grant Gustin, averaged a 2.5 rating in 18-49 and 9.6 million total viewers in L+7 — the show’s best numbers in the second half of its run.

Even though the ratings suggested a move to CBS’s sister net could be a possibility, despite the buzz, The CW has repeatedly denied reports and dismissed questions that “Supergirl” would land at the network.

The move marks the first time a show on the air has shifted from CBS to The CW. However, projects have moved within the CBS portfolio in the past. Last year, “Crazy Ex-Girlfriend” was developed at Showtime, but when the cabler passed on the Rachel Bloom comedy, CW picked it up. In 2011, Sarah Michelle Gellar’s “Ringer” was in the pilot phase at CBS, before being greenlit at CW.

Benoist plays the title character in “Supergirl” and stars alongside Calista Flockhart, Mehcad Brooks, Chyler Leigh, Jeremy Jordan and David Harewood. Hailing from Berlanti Prods. and Warner Bros. Television, Berlanti exec produces with Ali Adler, Andrew Kreisberg, Sarah Schechter.

Rick Kissell contributed to this report.