CAIRO — Egypt’s longtime president, Hosni Mubarak, was recovering in a hospital in Germany on Saturday night after what doctors called a successful operation to remove his gallbladder, according to Egypt’s official MENA news agency.

Mr. Mubarak, 81, temporarily turned over presidential authority to his prime minister, Ahmed Nazif, before his operation at the Surgical Hospital of Heidelberg University Hospital, the State Information Service said in a statement.

Mr. Mubarak’s sudden surgery came amid an already fevered discussion taking place in Egypt over the issue of succession. Mr. Mubarak’s term expires next year, leading to speculation as to whether he will retain control for another term in office, or whether his National Democratic Party will endorse his son, Gamal, for the post, or someone else.

Still, what was most extraordinary about the news of the president’s treatment was that it was made public at all, leaving many Egyptians surprised to see the news on television and in the morning papers. It was just in 2008, after all, that the state sentenced a popular newspaper editor to prison for articles reporting that the president was ill, though the editor was eventually pardoned.

“When you look at the Mubarak modus operandi, he is a military man. And with military men, things like the health of the general are military secrets,” said Hisham Kaseem, a former publisher and human rights advocate, who said he could not recall another time something like this had been announced in advance. “It’s a school of management.”

But the government and its supporters point to the public revelation saying that it was evidence the state was trying to become more transparent and leave behind its history of treating news of the president’s health as a state secret. In recent months, amid preparations for upcoming parliamentary elections in the fall, the government has become more active in trying to get its message out on many issues.

“It is proof that the concept has changed,” said Muhammad Abdallah, a leading member of the National Democratic Party. “The health of the president is an issue that is important and there is nothing wrong with him doing a check up or having an operation. Why should we keep it secret and give people the chance to spread rumors?”

After decades of secrecy, though, it is hard for people to accept that the government may now want to be transparent and truthful, Mr. Kaseem said.

“Are they giving the real reason?” Mr. Kaseem said many people were asking. “It really could be the gallbladder or it could be something more serious. That seems to be the question: Is it the gallbladder?”

Hospital officials gave details that suggested it was, after all, just a gallbladder operation. A hospital spokeswoman said that Mr. Mubarak was operated on by an expert in abdominal surgery, Markus Büchler.

Doctors from Heidelberg said last night on Egyptian television that the president had undergone successful open surgery to remove the gallbladder, was in stable condition and was expected to have a routine recovery.

“President Mubarak has fully recovered his consciousness and is meanwhile communicating with his family and his medical team,” Dr. Büchler said. “We have just spoken to him and he was making jokes with our team.”

Mr. Mubarak had been in Germany and met with Chancellor Angela Merkel on Thursday to discuss various issues, including the Middle East peace process.

He was taken to the hospital after reporting pain, and he was soon diagnosed with “severe inflammation of his gallbladder,” according to MENA.

Mr. Mubarak came to power in 1981, after the assassination of Sadat. In the ensuing years, it became taboo to discuss either the president’s health, or his mortality, or who will replace him. That has changed, especially as he approaches his 82nd birthday and the end of his current term.

Salama Ahmed Salama, who leads the editorial board of the independent daily newspaper Shorouk, said that the president was wise to announce this in advance, not to risk it leaking out, as has happened in the past.

“I think they are avoiding the mistakes of the past and working with transparency,” he said. “This is progress, although the progress is coming very late.”

Nicholas Kulish contributed reporting from Berlin, and Mona El-Naggar from Cairo.