CAIRO — The British government issued an apology on Thursday to a Libyan dissident and his wife for its role in a C.I.A. abduction in 2004 that landed them in Libya, where the man was tortured by Col. Muammar el-Qaddafi’s security forces and imprisoned for six years.

The apology to the dissident, Abdel Hakim Belhaj, and his wife, Fatima Boudchar, was the culmination of a six-year legal battle and represented a rare public rebuke by the British government of its own intelligence services.

“It is clear that you were both subjected to appalling treatment and that you suffered greatly, not least the affront to the dignity of Mrs. Boudchar, who was pregnant at the time,” Prime Minister Theresa May told the couple in a letter that was read out in Parliament.

“We are profoundly sorry for the ordeal that you both suffered and our role in it,” Mrs. May said.

Mr. Belhaj is a former leader of the Libyan Islamic Fighting Group, which tried to overthrow Colonel Qaddafi in the 1990s. After that effort failed, Mr. Belhaj fled into exile. In 2004, he and his Morocco-born wife, who was four months pregnant, were detained in Malaysia based on a tip by British intelligence operatives who told their American counterparts that the couple were suspected of having ties to Al Qaeda.