CARACAS, Venezuela — Explosions caused pandemonium at a military ceremony where President Nicolás Maduro of Venezuela was speaking on Saturday, making the first lady flinch and sending National Guard troops scurrying in what administration officials called an assassination attempt using drones.
The president, who was unharmed, later told the nation, “To all of our friends in the world, I am fine, I am alive.” He blamed right-wing elements and said, “The Bolivarian revolution keeps its path.”
Mr. Maduro has presided over a spectacular economic collapse in Venezuela, where inflation is expected to reach one million percent this year despite the country’s large oil reserves. Economists blame decades of mismanagement under Mr. Maduro and his predecessor, Hugo Chávez.
The drone attack was the latest in a string of attempts in recent years to end the tenure of Mr. Maduro, who was declared the victor of an election in May that carries his term until 2025. No previous assaults have been as bold, though, and this appeared to have been the first assassination attempt on a head of state using drones.
It was an attack that seemed scripted for Hollywood: Off-camera explosions. Low-flying drones exploding midair. The president and first lady ducking for cover. Thousands of soldiers in a military parade suddenly fleeing in a stampede that was broadcast to the country, live.
Jorge Rodríguez, the communications minister, said the attackers had used “several flying devices” that were detonated near where the president was standing.
The attack came shortly after 5:30 p.m. during an event the government said was meant to celebrate the 81st anniversary of the country’s National Guard.
During the president’s speech, which was broadcast live on state television, the camera began to shake. Mr. Maduro then looked into the air as his wife, Cilia Flores, flinched and reached for another official to brace herself.
The video feed was interrupted, but Mr. Maduro could be heard continuing to talk as voices in the background yelled for people to flee.
The video feed then showed figures dressed in black breaking through a barrier from the sidelines of a wide street where hundreds of uniformed guardsmen were arrayed in formation. The figures in black ran toward the guardsmen, who abruptly fled in panic.
The transmission then cut off.
Mr. Maduro, addressing the nation just before 9 p.m., blamed right-wing elements in Venezuela and Colombia for the attack, and said that President Juan Manuel Santos of Colombia was also responsible.
“All the investigations point to Bogotá,” he said, accompanied by his ministers and military high command. “They have tried to kill me today.” Mr. Maduro also suggested involvement by unidentified Americans.
Carlos Julio Rojas, an activist in Caracas, said that he had just arrived to protest water shortages when he felt the first explosion.
“We thought it was a bolt of lightning, but with the second explosion we could see the wall vibrating,” he said. “We saw the soldiers running.”
Mr. Rojas said neighbors told him they had seen drones approach and explode midair.
Figures aligned with the opposition condemned the attack.
“This is not the way out of the Venezuelan crisis,” said Nicmer Evans, a political scientist who has campaigned with the opposition. “No one wants the exit to be the death of someone to resolve this country’s situation.”
It was not the first time that the government, which has presided over years of food shortages and rules with an authoritarian fist, has suffered a spectacular attack in its capital.
In June 2017, Óscar Pérez, a rogue police officer, commandeered a helicopter and used it in a brazen midday assault to drop grenades on the Supreme Court building and to fire on the Interior Ministry.
Mr. Pérez took to Instagram to call for others to join his cause and wage attacks against military bases, but he was killed by the government during an assault in January.
In another attack last year, a group of soldiers struck a military barracks west of Caracas. Like Mr. Pérez, they released videos calling for others to join their cause, but no rebellion materialized.
And in 2016, Mr. Maduro himself was attacked by a mob who chased him down the street banging pots and pans and screaming that they had no food.
Despite widespread discontent, Mr. Maduro continues to hold power. His most popular rivals were banned from running in elections this spring, and opposition parties boycotted and said the vote was rigged.
Analysts said Saturday that while the attack might be used to drum up support for the president, it was a deep embarrassment for Mr. Maduro.
“It will boost his rhetoric and give some substance to his conspiracy theories,” said David Smilde, an analyst at the Washington Office on Latin America, a human rights group. “But the optics of this weaken him. The images of him being interrupted in mid-speech and the armed forces running away make him look vulnerable.”
Mr. Smilde dismissed theories on Saturday that the government had organized a failed attack to build support for Mr. Maduro. He said the attack appeared “amateurish.”
A United States State Department official said its Caracas embassy had issued a security alert. Leaders friendly to Mr. Maduro offered their support and cast suspicion on foreign powers.
“We energetically repudiate this new aggression and cowardly attack,” said Evo Morales, Bolivia’s president and a fellow leftist. “After failed attempts to topple him democratically, economically, politically and militarily, now the empire and its servants try to take his life.”
That wasn’t the reaction of some residents who stood nearby as officials fled.
“Running like rats,” said a woman who filmed a video of the soldiers and officials fleeing on Saturday. “All of those fancy cars of the plugged-in elites trying to get away at the same time.”
An earlier version of a photo caption with this article misspelled the name of the Venezuelan president’s wife. She is Cilia Flores, not Celia.
Ana Vanessa Herrero reported from Caracas, and Nicholas Casey from Popayán, Colombia.