The opposition candidate in Venezuela’s disputed July presidential election left the country on Saturday, the authorities said, as a standoff deepened at the Argentine diplomatic residence in Caracas where six Venezuelan opposition leaders have been sheltering since March.

President Nicolás Maduro has faced widespread domestic and international condemnation for proclaiming that he won that election, as well as for a violent crackdown on demonstrators protesting that declaration. The United States has said that the opposition candidate, Edmundo González, won.

On Saturday, Vice President Delcy Rodríguez said on social media that Mr. González had left for Spain after voluntarily seeking refuge at the Spanish embassy in Caracas. Spain’s foreign minister, José Manuel Albares, said that Mr. González was traveling on a Spanish Air Force plane at his own request.

“The government of Spain is committed to the political rights and physical integrity of all Venezuelans,” he wrote on X.

Mr. González was a retired diplomat with no political ambitions when he was plucked from obscurity in March to be a stand-in for the popular opposition leader María Corina Machado. A few weeks earlier, the Venezuelan Supreme Court had disqualified Ms. Machado from the election, a common tactic to keep strong competitors off the ballot. Those who know Mr. González said the role was not one that he had aspired to, but that he had accepted it out of a sense of duty.

On Monday, a Venezuelan court that deals with “crimes associated with terrorism” issued an arrest warrant for Mr. González. He was charged with conspiracy, usurping power, and sabotage, among other things.