SAN FRANCISCO -- Hundreds of people packed the rotunda of San Francisco City Hall to mark the 70th birthday of the signing of the United Nations charter.

U.N. Secretary General Ban Ki-moon, who travelled to San Francisco to mark the anniversary, called the two-month conference that led to the signing an audacious endeavour, one where a desire for a better world overcame the horrors of two world wars.

"Ladies and gentlemen, the drafting of the charter was a glorious gamble. Delegates from dozens of countries bet on humanity," he said, adding, "For two months, they turned San Francisco's War Memorial into a peace palace."

The United Nations was born on Oct. 24, 1945, after governments in a majority of countries approved the charter.

The ceremony on Friday was just one of several events on Ban's schedule. He received a medal from the Harvey Milk Foundation for his work on behalf of gay, lesbian, bisexual and transgender people around the world.

In the evening, Ban and other dignitaries were scheduled to dine at the Fairmont Hotel, where some of the negotiations took place in 1945.

The U.N., now made up of nearly 200 member countries, has the key goals of safeguarding peace, promoting human rights and delivering humanitarian aid. The mission in modern times has come to embrace climate change, gay rights and sustainable development, even as the world body confronts a series of stubborn conflicts in places such as Yemen, South Sudan and Syria.

Compounding the historic nature of the day was a decision by the U.S. Supreme Court that same-sex couples are free to marry anywhere in the United States -- a ruling welcomed by Ban and other political leaders who spoke at the U.N. commemoration.

San Francisco Mayor Ed Lee, California Gov. Jerry Brown and U.S. House Minority Leader Nancy Pelosi commented on the gay marriage ruling to applause from the crowd.

"Marriage equality, the rights of same-sex couples now recognized by the highest court of the land: Who would have ever thought that, even five years ago?" Brown said.

In the audience was 17-year-old Malala Yousafzai, a Nobel Peace Prize laureate who was shot by a gunman in 2012 for advocating education for girls in Pakistan. She sat serenely on the second floor of City Hall and waved to the crowd below and all around her.

Also in the audience was Libba Patterson, a 97-year-old woman whose San Francisco Bay Area family hosted a teenage Ban as part of an international Red Cross effort in 1962. It was the first trip abroad for Ban, who had suffered through the Korean War as a young boy, and who found relief in the food handed out by U.N. peacekeepers.

"San Francisco is not just the birthplace of the United Nations," Ban said. "For me, personally, it was the place where my passion as a young boy to be a global citizen, that was born."

Chris Whatley, executive director of the United Nations Association of the USA, said San Francisco was selected for the conference and eventual signing, partly, to remind nations that World War II was being fought on two fronts -- Europe and the Pacific. Plus, the city with its shipyards perfectly embodied the century's booming industrial economy.

"It was emblematic of America's economic power, and the U.S. host wanted to show what could be achieved in a nation at peace," Whatley said. "It was more than a venue for the negotiations. The city itself was a participant in the negotiations."