The city is withdrawing a divisive proposal to move a high-performing Brooklyn school into the building of its long-struggling neighbor, officials said Monday. But allies of the school indicated that another fight — over who should be the principal — is just beginning.

The plan would have moved Medgar Evers College Preparatory School, a selective school, into the building of Boys and Girls High School, long among the city’s worst-performing schools. It was first floated by Michael Wiltshire, who since 2014 has been principal of both schools in an unusual arrangement that even some former allies say has failed.

Supporters of Boys and Girls have in the past opposed plans that would limit the historic school’s use of its massive redbrick building in the Bedford-Stuyvesant section of Brooklyn. But it was parents from Medgar Evers who rejected the space-sharing proposal last month, angry that the city would not meet their demands.

Chief among the demands: that Medgar Evers students use a separate entrance at the Boys and Girls campus so they would not have to pass through metal detectors. That demand galled people at Boys and Girls and the other two schools in its building who felt that Medgar Evers was asking for special treatment.

The decision comes as Boys and Girls’ politically connected supporters are already discussing who will replace Wiltshire and what schools could share its Bedford-Stuyvesant building other than Medgar Evers.

Although Wiltshire has said he has not yet decided whether to step down as “master principal” of both schools, he has interviewed for a principalship in Long Island. He also told the Wall Street Journal last week that he was unsure whether he wanted to continue working for the education department after it was revealed that its investigators found he had failed to properly report an instance of student-on-student sexual harassment that occurred in December. Wiltshire said he had followed department protocol.

On Monday, several people at a meeting organized by the local education council said the school’s superintendent, Michael Alcoff, told them that the search for a new principal has already started. The community leaders, teachers union representatives, alumni, and others at the meeting said they want to make sure they are involved in choosing his replacement.

“It looks like a principal is going to be chosen, and I’m going to be pissed off if I’m not involved in that,” City Councilman Robert Cornegy said during the public meeting, where he promised to contact schools Chancellor Carmen Fariña about Boys and Girls’ future.

The city gave Wiltshire a large bonus and the title of “master principal” when he agreed to take over Boys and Girls in Oct. 2014. A few months later, he pitched the idea of combining that school with Medgar Evers, the selective school two miles away in Crown Heights that he has helmed for over a decade.

Wiltshire had long complained about Medgar Evers’ facilities: The building is so overcrowded that some of its 1,200 students must meet in outdoor trailers, while its track team must sprint down its hallways since the building lacks a gymnasium. Meanwhile, Boys and Girls’ sprawling building is only 25 percent occupied, according to the city.

“I see this as an opportunity to get the facilities that our kids deserve,” Wiltshire told Medgar Evers parents during a meeting last year about the plan. He added, “If we don’t move to that facility, someone else is going to take it.”

Eventually, the city made a formal proposal to move Medgar Evers into Boys and Girls’ building, though the schools would remain separate entities. Proponents of the move argued that it would also benefit Boys and Girls, since its students would be able to take honors classes at Medgar Evers and teachers at the two schools could collaborate.

But others felt that Wiltshire was mainly motivated by a desire to secure more space for Medgar Evers. In April, a Boys and Girls alumni group claiming to have 5,000 members sent a letter to Chancellor Fariña saying “the appearance of a conflict of interest” on Wiltshire’s part is of “grave concern.”

However, it was the resistance at Medgar Evers that appears to have convinced the city to drop the plan for now.

Last month, students and some parents held a rally against the move, and the school’s parent-faculty leadership team sent a notice to education department officials officially rejecting it. The team cited several reasons, including that Medgar Evers would only have access to some of the science labs in the shared building and that students would have to travel further to take early-college classes at Medgar Evers College.

The email also noted that Medgar Evers serves students in grades six to 12, while the Boys and Girls campus houses a “transfer school” for older students who struggled in previous settings. A “a significant number of them are older than 20 years old and some others are able to legally purchase, possess and use alcohol and tobacco,” it said.

Lorna Fairweather, a Medgar Evers parent and leadership team member, said in an interview last month that some parents were concerned about their children interacting with the older students.

“The parents do not want to have our sixth-graders commingling with 19 and 20-year-olds who are not in uniform,” she said, adding that they had a requested a separate entrance for Medgar Evers students.

Those concerns infuriated some people in the Boys and Girls campus, including the principal of the transfer school, according to people familiar with her thinking. Several people said they did not oppose the move, but they strongly rejected Medgar Evers’ demands.

“We welcome them, but we want it to be very clear that it will be equal,” NeQuan McLean, president of District 16 community education council, said at the meeting Monday morning before the decision to cancel the move was announced. “There will not be a separate entrance … We’re not going to stand for that kind of segregation.”

Deputy Chancellor Elizabeth Rose shared the decision with leaders at the Boys and Girls campus schools Monday afternoon. In an email, an education department spokeswoman said the agency was withdrawing the proposal while “further discussion and community engagement is underway.”

Even before the announcement, the Boys and Girls backers discussed other schools that could potentially move into its building if the Medgar Evers move fizzled. One possibility is Bedford Academy High School, a selective public school in Bedford-Stuyvesant, they said at the Monday morning meeting.

Several people also said the city’s experiment letting Wiltshire run two schools simultaneously had failed, and that his replacement should be dedicated solely to Boys and Girls.

“Turning a school around requires time, effort, energy, and commitment that one person cannot give to two schools,” said Sam Penceal, a 1962 graduate of Boys High and a leader of the alumni group.