CARACAS, Venezuela — Venezuela’s government expelled the German ambassador and detained a U.S. freelance journalist in Caracas for several hours Wednesday as President Nicolás Maduro sought to maintain control amid a Western-backed opposition campaign to unseat him.

The ambassador, Daniel Kriener, had been among a group of U.S., Latin American and European diplomats who greeted opposition leader Juan Guaidó at Caracas’s airport on Monday as he returned to the country after a 10-day trip abroad, defying warnings he might be arrested. 

“Venezuela considers it unacceptable that a foreign diplomat carries out in its territory a public role closer to that of a political leader aligned with the conspiratorial agenda of extremist sectors of the Venezuelan opposition,” Maduro’s government said in a statement.

Germany, the United States and more than 50 other countries have recognized Guaidó as Venezuela’s interim leader, in the wake of an election last year riddled with irregularities in which Maduro claimed a second term.

Earlier Wednesday, military counterintelligence forces raided the Caracas home of U.S. journalist Cody Weddle and took the Virginia native into custody. They also seized Weddle’s assistant, Venezuelan journalist Carlos Camacho.

Weddle and Camacho were released Wednesday evening, and the American journalist was deported, said Weddle’s lawyer, Theresly Malavé.

Malavé said  the journalist was questioned at the military counterintelligence headquarters and later driven to the airport to be flown out of Venezuela. The men were not charged, Malavé said.

U.S. diplomats earlier demanded Weddle’s release and sharply criticized the detention. The Venezuelan government did not say why he was being held and did not respond to calls seeking comment.

The State Department “is aware of and deeply concerned with reports that another U.S. journalist has been detained in #Venezuela by #Maduro, who prefers to stifle the truth rather than face it,” Kimberly Breier, the assistant secretary of state for the Western Hemisphere, said in a tweet. “Being a journalist is not a crime.”

Phil Gunson, a political consultant at the International Crisis Group, suggested the incident could strain already tense relations between the United States and Venezuela.

“Having military intelligence arrest a US citizen, freelance reporter @coweddle, seems like unnecessary provocation,” he tweeted. 

The two countries came to the brink of suspending relations in January but have maintained a limited diplomatic presence in each other’s capitals.  

Weddle, 29, has been a freelance journalist in Caracas for four years, producing TV and print content for, among others, ABC News, Canadian Broadcasting Corp. and the Miami Herald. 

As Maduro faces arguably the strongest challenge to his grip on power since becoming president in 2013, he is increasingly limiting media coverage by blocking websites, closing radio stations and intimidating reporters through the use of paramilitary groups.

Weddle’s detention came one week after Univision journalist Jorge Ramos was held in the presidential palace for hours, and his cellphone, cameras and SIM cards taken, after he asked interview  questions Maduro did not like. Ramos and his team were then deported.

About 7 a.m. Wednesday, a group of armed men, most of them dressed in black, approached Weddle’s Caracas apartment building, said Florangel Manzo, 49, the president of the condominium board. She said that one of the men showed her an order to raid Weddle’s apartment, adding that it came from a military tribunal, and said the journalist was being accused of “betraying the homeland.”

A security guard at the building, Juan Jose Araque, said in an interview that he saw five men dressed in black and carrying pistols in Weddle’s apartment on Wednesday morning. The guard said the security forces wore jackets indicating they were from the military intelligence service.

He said Weddle remained calm as the men packed some of his belongings in a suitcase and camera bag. “He didn’t look nervous. He had a sandwich before he left,” Araque said. About two hours after arriving, he said, the men escorted the journalist to a black Jeep and drove away. 

According to the country’s National Union of Press Workers, detentions have surged this year, with Camacho and Weddle joining 34 local and international reporters, photographers and producers taken into custody in the past two months. Most have subsequently been freed; some have been deported. 

Carol Morello in Washington contributed to this report.