The U.S. military is on the offensive in the War on Terror (search) to prevent terrorists from reaching America's shores, President Bush said Friday, adding that 20 years from now, historians will look back on the Iraq war as "America's golden moment."

"We are taking the fight to the enemy abroad so we do not have to face them here at home," Bush said in addressing the 2005 U.S. Naval Academy graduates.

Although what he called "difficult and dangerous work remains" in Iraq, Bush said he wanted to get U.S. troops home as soon as Iraqis could take control of their own country.

"Iraqis are determined and our strategy is clear — we will train Iraqi forces so they can take the fight to their enemy and defend their country. Then our troops can come home with the honor they have earned," Bush said.

The president also addressed the controversial issue of military base closures, saying some closures are necessary in an effort to help transform America's military.

The graduation ceremonies got under way with 21 cannon blasts and a fast and low flyover by the Blue Angels (search), the Navy's precision jet team. Six F/A-18 Hornets streaked in formation above the Navy-Marine Corps Stadium packed with thousands of cheering graduates, relatives and faculty.

Before he spoke, ebullient midshipmen got several rousing rounds of "the wave" going around the stadium at this prestigious academy on the shores of the Chesapeake Bay.

Bush hailed the U.S. military, particularly the Navy, for its role in the War on Terror.

"We're denying the terrorists sanctuary and making it clear America will not tolerate outlaw regimes that provide safe haven and support to terrorists," the president said. "The best way to protect our citizens is to stay on the offensive."

He noted that the U.S.-led coalition in the War on Terror has dealt "serious, powerful blows" to terror regimes within the past weeks.

The commander-in-chief also said downsizing military bases is a painful but crucial step in the process of transforming the U.S. military into the kind of fighting force especially suited for this age of terror.

"We have more bases than we need," Bush said. "Supporting these facilities wastes billions of taxpayer dollars -- money that can be better spent on giving you the tools to fight terrorists and confront 21st-century threats."

When Bush last spoke at a Naval Academy (search) commencement, it was four months before the Sept. 11, 2001, terrorist attacks and his focus was the top-to-bottom reshaping of the military into a faster, lighter, more flexible and more high-tech, but not necessarily larger, force.

That transformation is even more necessary now, Bush said, because of the attacks, and the two wars -- in Afghanistan and Iraq -- launched since. Technology, a massive redeployment plan and next-generation weapons are key to the transformation, he said.

"In this era of surprise, we cannot know for certain who might attack us or where or when," he said. "But we can anticipate how we might be attacked and we can transform our capabilities to defend our citizens and deliver justice to our enemies."

He added: "In this war, there is only one option and that is victory."

Bush also spoke for the first time publicly about how the process of closing bases fits into that larger vision, despite the fears in many military communities that he said he well understood.

"I know firsthand how hard base closings can be on local communities," said the former Texas governor who saw facilities shut down in his state.

He promised an "impartial and fair" process as a congressionally chartered commission reviews the Pentagon's sweeping proposal for closing or downsizing dozens of military bases large and small. The first round of base closings in a decade seeks to save $48.8 billion over 20 years by eliminating redundancy, streamlining services across the Army, Navy, Air Force and Marine Corps, shutting down bases deemed inefficient and promoting cooperation among the four branches.

The panel will spend the next few months deciding whether to change the proposal before sending it to Bush and Congress this fall.

"It will result in a military that is more efficient and better prepared so you can better protect the American people against the dangers of this new century," Bush said.

Bush, maintaining his tradition of rotating between the service academies for commencement ceremonies, also sought to inspire the military's future leaders.

Before the 976 graduates hurled their starched white hats into the blue sky and left the academy for their new status as military officers, Bush offered thanks for the many he addressed on the same field four years ago -- people who now are serving in difficult military operations in Iraq, Afghanistan and elsewhere. He recounted the brave deeds of several by name, and one whose name he said he could not reveal.

"Americans are grateful to have such brave defenders," Bush said. "They are serving our nation with valor and distinction and soon you'll join them."

"You will make America proud," he added.

The president softened up the crowd with a few jokes -- some at his expense.

"You threw pennies at Tecumseh, the god of 2.0. I knew him pretty well when I was in school," Bush joked, recalling his own academic mediocrity at Yale University.

He also brought what he said was his graduation gift to the class, a traditional offering at this event: absolution for all those on restriction for missing curfew or breaking other rules of conduct. That got a big cheer.

It was Bush's second and final commencement speech of 2005. Last Saturday, he spoke to the Calvin College graduating class in Grand Rapids, Mich.

After the graduation, Bush was traveling by helicopter to the Camp David presidential retreat in Maryland for the weekend. He is scheduled to return to Washington for Memorial Day events on Monday.

The Associated Press contributed to this report.