Channing Dungey, the first black executive to run the entertainment division at a major network, is leaving ABC, the company said Friday.

The move was announced just a few months before the Walt Disney Company, ABC’s corporate parent is scheduled to finish its acquisition of much of 21st Century Fox, which will greatly increase the company’s television holdings. The expanded Disney television empire will be overseen by incoming Fox executives.

Ms. Dungey, who took over the struggling broadcast network in February 2016, will be replaced by Karey Burke, a programming executive at the youth-oriented cable network Freeform. Ms. Burke will become the fourth person in eight years to hold the title of president of ABC entertainment.

Ms. Dungey was thrust into the spotlight earlier this year — an unusual spot for the publicity-shy executive — when the network made the sudden decision to cancel its biggest hit, “Roseanne,” after the show’s star, Roseanne Barr, sent a racist tweet. Ms. Dungey was widely praised — including by Shonda Rhimes, Ava DuVernay and Viola Davis — for her public comments that referred to Ms. Barr’s tweet as “abhorrent, repugnant and inconsistent with our values.”

But ABC has also struggled mightily in the ratings during Ms. Dungey’s tenure as the network’s entertainment president. It is once again in last place among the broadcast networks. In Ms. Dungey’s time at the network, ABC also lost Ms. Rhimes, the creator of “Grey’s Anatomy” and “Scandal,” and Kenya Barris, the creator of “black-ish.” Both signed lucrative deals with Netflix.

Still, the decision to leave was Ms. Dungey’s, and she will stay with the company for an unspecified amount of time to help with the transition. Her contract was set to expire early next year.

“This job has been the highlight of my career,” Ms. Dungey said in a statement. “While I’ve loved every moment, and knew I could call ABC home for many years to come, I’m excited to tackle new challenges.”

Robert A. Iger, Disney’s chief executive, said in a statement: “I’m grateful to Channing for her significant contributions and unwavering dedication to the success of ABC over the past 14 years. I’ve thoroughly enjoyed having the opportunity to work with and mentor Channing; her curiosity, passion, and creativity will ensure she is successful in whatever path she chooses going forward.”

Ms. Dungey’s departure is the latest move in an unusually tumultuous period in the executive ranks at the broadcast networks.

Leslie Moonves, the former chief executive of CBS who played a big role in the network’s programming decisions, was pushed out in September following multiple allegations of sexual misconduct. NBC’s entertainment chairman, Robert Greenblatt, stepped down the same month following a successful run. And in October, Fox announced that the AMC executive Charlie Collier would become the new entertainment head at the broadcast network.

Change was already coming to the executive ranks at ABC and Disney because of the pending deal with Fox. Peter Rice, a three-decade veteran at Fox, will become the chairman of Walt Disney Television. Dana Walden, the current co-chief executive of the Fox television group, will become the chairwoman of Disney Television Studios and ABC Entertainment.

Had Ms. Dungey stuck around, she would have reported to Ms. Walden. (Ben Sherwood, Ms. Dungey’s current boss and the president of the Disney-ABC Television Group, will leave the company once the sale is closed.) Now, Ms. Burke will take that role.

Ms. Burke joined Freeform in 2014 and worked for years as a producer before that. In the mid-1990s through 2003, she was an executive at NBC.

Ms. Dungey rarely strayed from talking points in gatherings with the news media, but Ms. Burke has been freer in her public appearances. When asked last year at a television conference in Austin, Tex., what she thought of Netflix’s free-spending ways, Ms. Burke replied pointedly, “With disdain.”

She will have plenty of work to do at ABC. Though ratings continue to slide through all of television, ABC has seen the biggest dip this season among the broadcast networks, an uncomfortable position for a network already stuck in last. There will be one pressing issue to deal with right off the bat: Several of ABC’s successful comedies — “Black-ish,” “Fresh Off the Boat,” “American Housewife” and “Speechless” — have seen an alarming drop in the ratings in the opening two months of the season, according to Nielsen.

In a statement, Ms. Burke said, “ABC is a beloved brand, and I am honored to continue the legacy left by Channing of excellent storytelling that touches so many people’s hearts.”