The head of Venezuela's opposition-controlled parliament was briefly detained days after saying he was ready to assume the country's presidency.
Juan Guaidó was travelling to a rally when intelligence agents intercepted his car north of the capital, Caracas.
The agents have been sacked over the "irregular procedure", part of a "media show" to benefit the opposition, the information minister says.
President Nicolás Maduro was sworn in for a second six-year term on Thursday.
The opposition calls him illegitimate and Mr Guaidó said on Friday he was ready to assume the Venezuelan presidency on an interim basis.
His wife, Fabiana Rosales, and daughter were travelling with him to a political rally in the coastal town of Caraballedas, opposition members said.
Ms Rosales announced her husband's detention on Twitter and video was posted on social media not long afterwards apparently showing the moment it happened.
He was released about an hour later.
The exact circumstances surrounding Sunday's events are still unclear, BBC South America correspondent Katy Watson reports.
But the arrest seems to be designed to send a message to those who oppose Mr Maduro, our correspondent adds.
What has the reaction been?
Information Minister Jorge Rodríguez said rogue agents of the intelligence agency, Sebin, had acted unilaterally.
Later, Mr Guaidó told supporters at a rally: "I want to send a message to Miraflores [the presidential palace] - the game has changed... Here we are! We are not afraid!"
He said Mr Rodríguez's comments were a sign that the government had lost control of its own security forces.
Two journalists who were covering the case - Beatriz Adrián, from Colombia's Caracol television, and Osmary Hernández, who works for CNN's Spanish language channel - were also briefly detained.
What's happening in Venezuela?
Earlier this month, Mr Guaidó became the speaker of the National Assembly, which has been stripped of its powers since Mr Maduro's ruling Socialist Party lost control of it in 2016.
Mr Maduro dismissed his comments as a "show". His re-election in May last year was marred by an opposition boycott and allegations of vote-rigging.
Since taking office Mr Maduro has been condemned at home and abroad for alleged human rights abuses and for his handling of the economy, which is in a state of near-collapse.
Venezuela is one of the world's largest oil producers but its overreliance on the product, which accounts for about 95% of its export earnings, left the country vulnerable when prices dropped in 2014.
As a result, the cost of imported goods like food and medicine has risen, and currency inflation has skyrocketed.
The government is also increasingly struggling to get credit after it defaulted on some of its government bonds. In response, the government has printed more money, devaluing the currency further.
Mr Maduro was first elected in 2013, succeeding Hugo Chávez who died of cancer after governing for 14 years.