With hymns, prayers and eulogies, the nation bade farewell to Ronald Reagan today in a state funeral attended by U.S. and world leaders in Washington's National Cathedral.

"Ronald Reagan belongs to the ages now, but we preferred it when he belonged to us," President Bush said in the last of four eulogies for the nation's 4oth president as his body lay in a flag-draped casket before about 4,000 invited guests.

Hailing Reagan as a leader of steadiness, calm and constant good cheer, Bush said, "He was optimistic that liberty would thrive wherever it was planted, and he acted to defend liberty wherever it was threatened. . . . When he saw evil camped across the horizon, he called evil by its name." Bush referred to Reagan's renowned speech in which he called the former Soviet Union an "evil empire," and he noted that when Reagan said those words, "there were no doubters in the prisons and gulags" of the vast communist state.

"We know, as he always said, that America's best days are ahead of us," Bush said. "But with Ronald Reagan's passing, some very fine days are behind us, and that is worth our tears."

The eulogies -- sprinkled with both solemn remembrances and humorous anecdotes -- were delivered as Reagan's widow, former first lady Nancy Reagan, sat in the cathedral's front row with her family. At times, tears welled in her eyes as the speakers recalled their experiences with her husband of 52 years.

"We've lost a great president, a great American and a great man, and I have lost a dear friend," said former British prime minister Margaret Thatcher in a videotaped tribute that was played as she sat in a pew next to former Soviet president Mikhail Gorbachev.

While others prophesied the decline of the West, she said, Reagan "inspired America and its allies with renewed faith in their mission of freedom." Thatcher added, "He won the Cold War not only without firing a shot, but also by inviting enemies out of their fortress and turning them into friends."

"With the lever of American patriotism, he lifted up the world," she said. Around the globe, especially in Eastern Europe and in Moscow itself, "the world mourns the passing of the great liberator and echoes his prayer, 'God bless America,' " Thatcher said.

Brian Mulroney, the former prime minister of Canada while Reagan held office, recalled that Reagan once remarked to him during an appearance with their wives, "You know Brian, for two Irishmen we sure married up."

Former president George H.W. Bush, who served as Reagan's vice president for eight years, choked up as he said he learned more from Reagan than from anyone else he encountered in all his years of public life. "I learned kindness," Bush said. "I also learned courage . . . and I learned decency. The whole world did."

The elder Bush said he also "learned a lot about humor." He recalled once asking Reagan how his visit had gone with South Africa's Bishop Desmond Tutu. "He replied, 'so-so,' " Bush said.

His son, the current president, said in his own eulogy that before Reagan's political career began, fellow actor Robert Cummings once suggested he run for president. He said Reagan replied, "What's the matter, don't you like my acting either?"

President Bush also told of a boy who once wrote to Reagan to request federal assistance to clean up his bedroom.

"The president replied that 'unfortunately, funds are dangerously low,' " Bush said to laughter. "He continued, 'I'm sure your mother was fully justified in proclaiming your room a disaster. Therefore, you are in an excellent position to launch another volunteer program in our nation. Congratulations.' "

Before the eulogies, Justice Sandra Day O'Connor, appointed by Reagan as the first woman to sit on the Supreme Court, read from one of Reagan's favorite sermons, one by John Winthrop that dates from 1630 and that inspired Reagan's oft-quoted description of America as "a shining city upon a hill."

"For we must consider that we shall be as a city upon a hill," O'Connor read. "The eyes of all people are upon us."

As the funeral drew to a close, Irish tenor Ronan Tynan, an opera singer who appeared at the request of Nancy Reagan, sang "Amazing Grace."

To the strains of "God Bless America," Reagan's flag-draped casket was then carried out of the cathedral and placed in a black hearse for a trip to Andrews Air Force Base southeast of Washington.

After a departure ceremony at Andrews, the casket was loaded aboard an Air Force 747. Nancy Reagan and family members -- joined by, among others, Margaret Thatcher -- then climbed the aircraft's steep, red-carpeted stairs. The blue and white plane took off a few minutes before its scheduled 2:45 p.m. departure time for the five-hour flight to Reagan's home state of California. There, his body is to be buried at his Simi Valley presidential library in a sunset ceremony.

Before the state funeral, the nation's first in more than 30 years, Reagan's casket lay in state in the Capitol Rotunda for more than 36 hours. Reagan died at his California home Saturday at age 93 after a 10-year battle with Alzheimer's disease.

After a period of public viewing ended, Nancy Reagan entered the Rotunda shortly after 10 a.m. EDT and approached the casket lying on a wooden platform, called a catafalque, that dates from the funeral of Abraham Lincoln.

The 82-year-old widow ran her hands over the American flag covering the casket, whispered a few words as if speaking to her departed husband and gently kissed the flag. After a final farewell pat, she made her way out of the Rotunda on the arm of Maj. Gen. Galen B. Jackman, the commander of the U.S. Army Military District of Washington, who has escorted her throughout the six days of public ceremonies.

Nancy Reagan and members of the Reagan family then waited at the bottom of the Capitol's western steps while Army howitzers fired a 21-gun salute and the casket was carried down to a waiting hearse. Standing under an umbrella, Nancy Reagan held her right hand over her heart as the casket was placed in the hearse.

Under cloudy skies and drizzling rain, crowds gathered in the streets of the capital to watch the hearse containing the mahogany casket make the five-mile trip to the cathedral from the Rotunda.

By the time public viewing ended at 8 a.m. EDT, more than 104,000 people had filed past the casket in the hushed Rotunda, according to U.S. Capitol Police Chief Terrance W. Gainer. As they did so, the silence was broken only by the shuffling of feet and the periodic changing of the joint honor guard composed of members of the armed services.

Well before the funeral service began, mourners had staked out spots near the National Cathedral around the intersections of Massachusetts and Wisconsin Avenues NW. They sat on the curb, rain jackets and coolers by their sides, cameras and video recorders ready to capture the moment of history that soon would pass before them.

A block or two past the cathedral, the flags of dozens of countries stood at half staff at the diplomatic missions and the Islamic Center on Embassy Row. Police cars and uniformed officers were posted every few blocks and clustered thickly around the vice president's residence at Observatory Circle.

Pamela Scallan sat on a windbreaker on the ground at the corner of Fulton Street and Massachusetts Avenue to get a front-row spot almost two hours before the motorcade passed. Scallan, owner of a women's clothing store in the District, said she turned out today out of respect for Reagan's leadership.

"I thought he really had a vision and so many of our politicians do not," she said. "Just listening to the polls is no way to run a government."

More than 2,000 spectators lined Massachusetts Avenue in the final six blocks of the motorcade's route. Many parents brought toddlers and infants to witness the event.

The quiet there was broken only by the occasional shouts of about 10 anti-gay Baptist protesters from Kansas who condemned Reagan and President Bush, and by the retorts of people who were appalled at the protesters' message and shouted them down. The Baptists accused Reagan of not having done enough to stop "the sin of homosexuality."

Several other protesters carried signs criticizing Reagan's policies and accusing him of causing death and suffering during his presidency. One sign said, "Remember Reagan's victims."

In another part of the city, about a dozen activists from a group called District's Anti-War Network (DAWN) carried hand-lettered signs critical of Reagan. "Ronald Reagan's Victims," read one sign, showing several tombstones. "Lebanon. People With Aids. Nicaragua. El Salvador. The Poor. Honduras. Libya." At the front of the vigil, a protester held a placard reading, "It's Fascism Again in America."

At the gothic cathedral, the invited guests gathered for the funeral service throughout the morning. In addition to President Bush and his father, the gathering included more than two dozen current and former presidents and prime ministers from various countries.

Besides Thatcher, British attendees included Prime Minister Tony Blair and Prince Charles. German Chancellor Gerhard Schroeder, Italian Prime Minister Silvio Berlusconi and Irish President Mary McAleese were among the other current leaders at the service.

In addition to former president Bush, the three other living former presidents -- Gerald Ford, Jimmy Carter and Bill Clinton -- attended the funeral.

Among the many lawmakers in attendance was Sen. John F. Kerry of Massachusetts, the Democratic Party's presumptive nominee to run against President Bush in November. He sat in the third row stage left, with much of his view blocked by the cathedral's massive pulpit.

As the gathering awaited the arrival of Reagan's casket, Tynan sang Franz Schubert's "Ave Maria."

The interfaith service was led by John C. Danforth, an Episcopal minister and former Republican senator from Missouri who was recently chosen by President Bush to become the new U.S. ambassador to the United Nations. The service also included the participation of Roman Catholic, Jewish, Greek Orthodox and Muslim clergymen.

The streets of Washington were quieter than usual as the motorcade traveled to the cathedral, President Bush having declared today a national day of mourning and a federal holiday. The Washington, D.C., government followed suit, closing city offices and schools.

Dozens of blocks were closed to traffic as motorcades bearing world leaders converged on the cathedral.

As part of a final day of ritual and tribute, American military bases around the world scheduled 21-gun salutes at noon, followed by a round of 50-gun salutes at dusk.

In what organizers described as a new tradition, the cathedral rang its bell 40 times following the funeral -- symbolizing Reagan's standing as the 40th president. Churches across the nation were invited to join in that gesture by ringing their own bells 40 times at around 1:15 p.m. EDT.

Staff writers Debbi Wilgoren, Sari Horwitz, Avram Goldstein, Valerie Strauss and Mike Allen contributed to this report.