Mr. Pérez then unfurled a banner calling on Venezuelans to rebel against Mr. Maduro, to the cheers of protesters below. He later released a video in which he and a masked band repeated their calls of rebellion.
While no one was injured in that attack, it was an embarrassment for the government, and it vowed to capture him.
It also signaled the rise of one of the most improbable figures in Venezuela’s political turmoil last year: a police officer who had once starred in a low-budget action movie about a crime squad. Now, it seemed, he was playing a real-life version of the character he had portrayed.
On Monday, Venezuelans were glued to the unfolding events on social media. Early in the morning, Mr. Perez announced that his location had been discovered. Then he began releasing a series of videos.
“We’re negotiating with the officials and the prosecutors,” he says calmly into the camera in one of the first messages, appearing in a dark room. Other rebels can be heard in the background shouting into phones.
In a later video, posted after daybreak, Mr. Pérez turns the camera outside, where government officials can be seen calling up to him.
“We’re not criminals,” he tells them. “We’re patriots who are fighting for our convictions.”
In the videos, Mr. Pérez is heard saying repeatedly that his group will surrender because it is accompanied by civilians. He says they do not want a fight.
But in a later video, the two sides appear to have stopped talking and begun battle. A rebel in a helmet and flak jacket can be seen taking cover beside a wall while another holds a rifle behind a filing cabinet.
“Hold your fire!” someone shouts.
While Mr. Pérez said last year that he had hoped others would take up his call, he has looked increasingly alone in recent months.
After appearing in public during an anti-government rally in July, Mr. Pérez largely disappeared from public view. While some members of the security forces staged rebellions of their own in the time afterward, top military officials stayed loyal to Mr. Maduro’s government. Mr. Pérez’s abandoned helicopter was found by the government shortly after the June attack.
Perhaps most demoralizing to Mr. Pérez and his followers was the disbanding of street protests against Mr. Maduro that took place after the president consolidated power by dissolving the opposition-controlled Congress and establishing a new one packed with loyalists.
On Monday, a video attributed to Mr. Pérez’s mother was posted on Twitter in which she pleaded with the government to allow him to surrender.
But the firefight continued.
“They’re throwing grenade after grenade,” he said, his face bloodied as he crouched behind an oven with his rifle. “They’re shooting at us. Venezuelans: Freedom forever!”
In one of the last messages, Mr. Pérez appears exhausted. His face is covered with blood and he is panting. The sounds of gunshots ring in the background.
“They don’t want us to surrender,” he says.