Mayor Bill de Blasio's pick to be the next city schools chancellor has turned down the job offer, after facing emotional pleas in his school district to change his mind in a riveting meeting in Miami on Thursday.

Miami-Dade County Public Schools Superintendent Alberto Carvalho faced a wave of praise during an emergency school board meeting that stretched for about four hours on live TV.

"Against probably my personal best interest," Carvalho said to the audience in Florida. "I shall remain in Miami-Dade as your superintendent," Carvalho said to a roar of cheers from people who attended the meeting.

Carvalho faced an emotional meeting Thursday, with Miami residents, members of the school board, students, teachers, union officials, custodians, and superintendents all asking him to stay in his position as Miami-Dade County public schools superintendent.

"You're the right leader. You're the right leader we need," one member of the Miami school board said.

"If there's that unfinished business, I believe that if there's anybody that can do it, it's you," said another member of the school board.

After he was lavished with praise, it was Carvalho's turn. He gave a soaring speech, touching on his upbringing in Portugal, pleading for gun control, and arguing for immigrants' rights.

One moment, it appeared he would stay; the next he appeared bound for New York City: "The chancellor's position in New York City is the most coveted job in education," he said.

The drama unfolded on social media and live TV Thursday morning and afternoon, as many people followed along in New York and Miami, wondering what would be Carvalho's decision. Carvalho ended up trending on Twitter in the city, as elected officials, journalists, and advocates kept weighing in on the spectacle.

Carvalho took two breaks: First, he said he had to "do something honorable." When he returned, he said he had reached a decision but needed to make a call:

"I need another little recess," he said.

"Yes, sir," a member of the school said immediately, leading to more suspense.

He returned to the meeting around less than 20 minutes later, having emerged after reaching de Blasio by phone.

"I underestimated the emotional tug, the level of commitment, the power that crying members of the community have had on me," the Miami superintendent said, just before announcing he would not take the job in New York.

Carvalho later said that speaking to children, who implored him to stay, had the greatest impact on him, convincing him to change his mind.

De Blasio's press secretary Eric Phillips said, after Carvalho rejected the job offer, that the Miami superintendent had agreed to become the next city schools chancellor until the emergency meeting:

The mayor said Carvalho and he agreed to make him the next chancellor about a week ago and was surprised by the Miami schools chief's decision Thursday.

"Never had a situation like this before," de Blasio said during a press conference Thursday evening.

Carvalho said he spoke to de Blasio during a recess during the emergency meeting, letting him know "it was not an easy conversation" to reject the job offer.

Carvalho said he agreed with the mayor on numerous positions, from teachers' salaries to not arming teachers with firearms.

"There was no anger," Carvalho said. "I am saddened and disappointed over the fact that I may have let down the aspirations and hopes of the great city of New York. But I have to, first and foremost, be true to this community and true to myself."

Carvalho, 52, has served as the superintendent for Miami-Dade County public schools since September of 2008.

Under Carvalho, Miami-Dade expanded choice options to include over 500 offerings, including programs in fine and performing arts, biotechnology, engineering, and forensic sciences.

In a statement Wednesday, before Carvalho changed his mind, de Blasio said, "Alberto Carvalho is a world-class educator with an unmatched track record of success. I am very confident that our extensive, national search has found New York City the best person to lead the nation's largest school system into the future. I look forward to welcoming our new chancellor to New York City in the days ahead, and to working with him in the years ahead as we deepen achievement in our classrooms and build on the outstanding record of accomplishment that Chancellor Fariña has delivered for students and their families across the five boroughs."

Carvalho would have served as the schools chancellor for the remainder of de Blasio's last term as mayor, which ends in January of 2022.

Miami-Dade County's school system is the fourth-largest in the United States. New York City has the largest, with about 1.1 million students. The population of Miami's schools is similar to the city's, with mostly black and Hispanic students, most of whom qualify for free or reduced-price lunch.

De Blasio now restarts his search for a replacement Carmen Fariña, 74, who announced in December that she will retire. The mayor had undertaken a national search for a replacement to Fariña, who is expected to retire at the end of this month.

Carvalho, a career educator, is seen as a superstar in the superintendent's world, having brought the graduation rate in his school system from about 60 percent to about 80 percent.

The city had offered to match his higher salary in Miami so Carvalho could take the city chancellors job, which is seen as the most prestigious education job in the country.

Carvalho, who came to New York from Portugal at the age of 17 but overstayed his visa and was undocumented, speaks multiple languages. He then went down south, where he has been for most of his career.

Fariña has overseen the city's school system for the past four years, and had spent decades in the city education department as a teacher, an assistant principal, principal, superintendent, and deputy chancellor. She was not expected to stay on for a second term.

Fariña came out of retirement when de Blasio convinced her to become his schools chancellor.

During her time as chancellor, she oversaw the public school system start universal pre-kindergarten.

The mayor said at the press conference Thursday that Fariña will stay in her post through the end of March, but he did not commit when asked if there would be a new chancellor by the end of the month.