(CNN) -- A defiant Ecuadorian President Rafael Correa returned safely to the presidential palace late Thursday after spending hours held by police inside a hospital room outside Quito.
Minutes earlier, members of the Ecuadorian army -- wearing gas masks -- rescued him, a reporter for Ecuadorian Television reported.
Speaking from a balcony, Correa told thousands of jubilant supporters that he saw one person who was shot during the rescue, which he regretted.
He thanked his supporters -- in particular his bodyguards -- for standing behind him and said the rebel police effort to oust him had failed.
"Nobody has supported the police as much as this government, nobody has increased their salaries as much," he said about police protests about what they thought were salary cuts. "After all we've done for the police, they did this!" he said, adding that he was held inside the room and not allowed to leave.
"Supposed national police!" he spat. "Shame on you!"
"We never accept negotiating anything under pressure," he added.
Correa also said the actions of the police left him "profoundly sad, like there was a knife in my back."
Earlier Thursday, national police took to the streets of Quito, the capital, and physically attacked the president over what police said was the cancellation of bonuses and promotions.
The minister of security, Miguel Carvajal, said one person was killed and several were wounded, but did not offer details.
The government declared a one-week state of emergency Thursday afternoon and put the military in charge of security. The military said it will support the president and the nation's democratic institutions.
"This is a coup attempt," Correa said in a TV interview from the hospital, where he had been taken after police lobbed tear gas at him.
Correa, 47, said police were trying to get at him there.
"They're trying to get into my room, maybe to attack me. I don't know," he said in a telephone interview with state-run Ecuador TV, referring to his attackers as "cowards."
"But, forget it. I won't relent. If something happens to me, remember my infinite love for my country, and to my family I say that I will love them anywhere I end up."
A video by CNN affiliate Ecuavisa later showed a defiant Correa standing at an upper floor window, shouting to a crowd of supporters who had gathered outside the hospital, "If they want me, here I am," and then ripping his necktie loose.
Later, he told a television station by telephone from the hospital that, if he were killed, he would be replaced by thousands of revolutionaries. "The most I have to lose is my life," he said. "They're going to achieve absolutely nothing!"
But Doris Solis, the coordinating minister of politics, disagreed with his characterization of events. "This is not a coup," Solis told CNN en Espanol.
Correa said a law passed Wednesday by the National Assembly does not cut compensation bonuses of police, as some have asserted, and he accused the news media and his political opponents of misinforming the public about the legislation.
Thursday night, he said that police -- "not one of them" -- had read the law.
"When they demanded that I revoke the law to let me out, I told them, 'Don't waste time with me. I leave as president of a dignified nation, or I leave as a cadaver," he said, his voice hoarse from shouting into a microphone.
"Of course, the law will not be revoked," he added, stabbing his finger into the air for emphasis.
Meanwhile, schools were closed, and children were sent home around noon Thursday. The schools are to remain closed Friday and until a new mandate overturns the decision.
"We can guarantee the citizens that order and security are slowly being re-established," a military official, Commandant Jorge Gross, said on television at 6:30 p.m. (7:30 p.m. ET).
But that was not clear everywhere during the day Thursday.
A spokesman for government-run television said police were trying to cut the station's power supply. As the station's anchors reported the news, cameras showed people trying to enter the studio by pushing on a locked glass door. A few minutes later, the camera shot cut to a different studio, and a station manager said protesters had broken into the studio and shattered windows in the building.
A broadcast by Ecuador TV showed mobs on the streets and clouds of black smoke rising from burning tires and garbage. Sporadic looting was reported.
But by dusk, officials reported that the situation appeared to be stabilizing. "We've taken control of all of the city of Guayaquil as of 5 p.m.," (6 p.m. ET), said Roberto Cuero, governor of Guayas province. "The city has begun to recover tranquility."
Guayaquil, Ecuador's largest city and the birthplace of Correa, was under military control.
The challenge to Correa occurred after he had taken to the streets to try to negotiate with police but was soon surrounded and jostled by a crowd. He then fled after someone fired a tear gas canister at him. Some of those shoving him were dressed as police officers in full gear.
Video from CNN affiliate Teleamazonas showed a man in a tan suit punching Correa and trying to yank a gas mask off the president's face.
The broadcast then showed a hunched-over Correa being led away, his face still covered by the gas mask. Correa, who recently underwent knee surgery, leaned on a crutch with his left arm.
A news photograph later showed him lying on a stretcher.
A government helicopter had tried to evacuate him but was unable to land.
He went on the air from the hospital a couple of hours later to denounce what he called a cowardly attack.
"They fired gas on us -- on the president of the republic," Correa said in a telephone interview with Ecuador TV. "This is treason to the country, treason to their president."
Ecuador has nearly 58,000 members in its military and 33,000 in the national police force, according to Jane's Intelligence Review.
The military, Jane's said, is undergoing a professionalism transformation designed to give it greater flexibility.
The National Civil Police, meanwhile, is the nation's major law enforcement organization.
Government officials tried to quell the rebellion, insisting that the security forces had been misinformed and warning that the nation's democracy was in danger.
"I want to tell the country there has been an attempt at a coup," said Gabriel Rivera of the Country Accord Party.
"This is a Machiavellian plan organized by sectors of the right," Rivera said on Ecuador TV.
A police spokesman went on the air on Teleamazonas to dispute the government's allegations, saying that the security forces were in fact supporting Correa.
"Fellow officers who hear me nationally, stop this action," said the spokesman, identified only as Sgt. Mejia. "Don't close the streets. Return to the streets to work."
The disturbances occurred as Correa threatened to dissolve the National Assembly over a dispute about several laws, including public service and education.
Angry police said they were overworked and underpaid.
"We work 14 hours a day," a uniformed officer said on Ecuador TV. "We are the ones who never protest."
Peru closed its border with Ecuador, and messages of support for Correa came from 10 Latin American nations: Argentina, Venezuela, Mexico, Colombia, Peru, Chile, Bolivia, Costa Rica, Cuba and Honduras. The Organization of American States also voted to support Correa.
Colombian President Juan Manuel Santos said on Caracol TV that he was closing his country's border with Ecuador.
Correa was elected president in 2006 and took office in 2007. He earned a Ph.D. in economics from the University of Illinois at Urbana-Champaign in 2001.