The jailed mayor of Venezuela's capital has been transferred from prison to a hospital where he will undergo emergency surgery for a groin hernia.

Antonio Ledezma was transferred early Saturday after a Caracas court ordered his release on medical grounds, according to his lawyer Omar Estacio. Following the procedure he will be allowed to recuperate at home.

Ledezma was treated for the same ailment before his arrest.

The opposition leader was arrested by police during a dramatic raid on his office in February and he has been held at a military prison on charges of plotting a coup against the South American country's socialist government.

The mayor denies the allegation.