ISLAMABAD, Pakistan—Ex-President Pervez Musharraf was charged in court with a role in the 2007 assassination of former Pakistani Prime Minister Benazir Bhutto, his most serious legal setback since his return to the country in March.

The onetime military ruler was charged in a Pakistani antiterrorism court on Tuesday with criminal conspiracy and facilitation of murder, lawyers said. Mr. Musharraf pleaded not guilty.

Ms. Bhutto was killed by a suicide bomber as she left a political rally in the city of Rawalpindi in December 2007, when Mr. Musharraf was president. The case promises to test relations between Pakistan's civilian authorities and its powerful military. Mr. Musharraf was army chief when he seized power in October 1999, ousting then-Prime Minister Nawaz Sharif and later making himself president.

Mr. Musharraf returned from four years of self-imposed exile to Pakistan in March this year with the aim of taking part in May elections. He was barred from politics, however, while Mr. Sharif proceeded to reclaim the premiership.

Mr. Musharraf appeared in the court on Tuesday in Rawalpindi, near the capital Islamabad, amid tight security.