CAIRO – Egypt’s Islamist president told his opponents to use elections not protests to try to change the government and said the military should focus on its role as the nation’s defenders in a nationally televised address on Wednesday, days before the opposition plans massive street rallies aimed at removing him from office.

Mohammed Morsi’s words to the military came amid opposition hopes that the powerful generals will protect their protests Sunday in an implicit show of support. Morsi’s supporters accuse the opposition of fomenting a coup. Speaking at a giant conference hall packed with people, Morsi reminded his audience that “all agree” that the president is the supreme commander of the armed forces.

“There are some who don’t want the armed forces and the presidency to have a healthy relationship,” Morsi said. “All state institutions work in harmony and with discipline under the leadership of the head of state.”

The audience, packed with Cabinet members, officials from Morsi’s Muslim Brotherhood and other supporters, cheered his remarks on the military, which at times sounded like a rebuke to Defense Minister Abdel-Fattah el-Sissi.

Sitting on the front row, el-Sissi, sat silently. Days earlier he issued a sharp demand that both sides in the crisis reconcile and a warning that the military will not sit by if the nation is endangered by the political divisions.

Earlier on Wednesday, military officials said they were bringing reinforcements closer to Egypt’s main cities, apparently aimed at keeping security if violence erupts on Sunday.

In his 2½-hour address, Morsi defended his performance in his first year in office, admitting to making mistakes but also claiming achievements. At one point he apologized for fuel shortages, which have caused long lines at gas stations and have increased frustration and anger at the government. “I am saddened by the lines, and I wish I could join in and wait in line, too,” he said. At another, he apologized to the nation’s youth for not doing enough to involve them in the new political system and ordered Cabinet ministers and provincial governors to appoint assistants under the age of 40.

But he offered no compromises in the confrontation with his opponents. Those organizing the protests for Sunday — the anniversary of Morsi’s inauguration — say he must go because he has mismanaged the country, given a monopoly on decision-making to the Brotherhood and his Islamist allies and has encroached on the judiciary.

Protesters are hoping to bring out massive crowds Sunday, saying they have tapped into widespread discontent over economic woes, rising prices and unemployment, power cuts and lack of security.

As Morsi spoke, several thousand of his opponents gathered in Tahrir square, the birthplace of the 2011 uprising that toppled autocrat Hosni Mubarak, chanted “erhal!” or leave. Some chanted “the people want to overthrow the regime.” Several took off their shoes and held them up in a sign of contempt.

Morsi took aim at his opponents and critics. He demanded “some in the media stop spreading rumors.” He told the judiciary, with which he has clashed repeated over the past year, to stay out of politics, though he added he “respects very, very much” their status.

He told his political opponents to “enter elections if you want to change the government” and scolded them for brushing off his past appeals to hold a dialogue on the nation’s problems. “I have been surprised” by their refusals, he said repeatedly.

Morsi said protests were a legitimate way “to raise your opinion” but they cannot be “used to impose your opinion.”

Morsi’s supporters say the protest organizers are trying to overturn democracy by reversing the election victories of Morsi and his Islamist allies. They have accused Mubarak loyalists of trying to foment a coup.

In the speech, Morsi was often animated, at times angry, raising his voice. He frequently departed from prepared remarks, switching from formal Arabic to Egyptian dialect to make jokes and present a common-man image. He was rewarded with applause from supporters who, after the speech, chanted “Oh president, we love you!”