The first bank in San Francisco opened on Jan. 9, 1849, and no one has had more fun near the teller’s window in the 16 decades since.

Henry M. Naglee hatched his banking plan when he saw office space open next to the Parker House on Kearny Street, one of the city’s most popular spots for gambling and other sinful distractions of the time.

“Naglee promptly bought the adjoining lot, rushed up a stout frame building and therein opened San Francisco’s first bank,” The Chronicle reported years later. “The bank did not need much space. Later, the shrewd old boy leased part of his building to a barroom.”

Banking in San Francisco began with an Old West mentality and questionable decision-making. At Naglee’s short-lived Exchange and Depot Office, whiskey could be purchased and consumed just a few feet from the safe. But this innovative spirit was quickly matched by its scruples. As much as by the hard work of labor and the ingenuity of architects and engineers, San Francisco was made by its bankers.

It’s a tough narrative to latch onto in the 2000s, as U.S. banking recovers from some reputation-decimating events. But the San Francisco bankers of the last half of the 1800s and first half of the 1900s could be downright heroic, showing leadership and loyalty after the 1906 earthquake and the Great Depression. It’s not a coincidence that two of the “big four” banks in the nation — Wells Fargo and Bank of America — have strong roots in San Francisco.

In the early days of the Gold Rush, when men flowed to San Francisco faster than currency did, there were too few coins in circulation to operate under more than a barter economy; purchases in the late 1840s were often made with pelts, livestock and gold.

“In barrooms the custom was for saloon owner or barkeep to take his ‘pinch’ of gold dust from the thirsty miner’s poke,” Chronicle historian E.G. Fitzhamon wrote in 1929. “There used to be told a story about Flood & O’Brien saloon on Washington Street — one of (the barkeeps) was much envied by rival saloon-keepers, blessed with a large and spatulous forefinger and thumb.”

Another oft-told newspaper legend had a miner paying his doctor’s bill “by two cows in full.”

The first banks sprang up out of necessity, and the only prerequisites were a good safe and a reputation as an honest citizen. In the early days, there were plenty of the former but not enough of the latter. Disruptions in the 1850s economy — including a real estate speculation crisis and a cholera outbreak — caused panic in the industry that sank many bankers. (Naglee stuck around for only 19 months — retiring to San Jose to make high-end brandy for himself and close friends.)

But in this land of early innovators, three bankers stood out for their stubborn, enterprising spirit.

• Henry Wells and William G. Fargo: These ambitious bankers, who set up shop in San Francisco in 1852, seemed to think bigger than the rest. Wells Fargo & Co. eventually helped with the growth of the Pony Express, and developed its cross-country stagecoach line that remains the company’s symbol. (Side note: Earlier Wells advertisements in The Chronicle feature a clipper ship as a logo.)

• Amadeo Peter “A.P.” Giannini: His innovative Bank of Italy, founded in San Francisco in 1904, shifted the focus of banking beyond the wealthy, offering immigrants and laborers the same services. Later, he became a pioneer in branch banking — fighting against government rules that all but outlawed bank chains. Corporate giant Bank of America is part of Giannini’s legacy, but his early role was as a banker for the people.

The Nevada National Bank, founded in 1875 by four men with strong San Francisco ties, was another banking powerhouse, merging with Wells Fargo in 1905. Crocker National Bank and Hibernia Bank, both headquartered in San Francisco, were also major players. When the 1906 earthquake hit, banks were at their strongest and as organized as any business in the city.

Civic agencies reeled in the days after the April 18, 1906, disaster — the fire chief was dead, and the police and military ruled the city under martial law. While much of the city was in a panic, the bankers met as a group, acted decisively and preached calm.

“No San Francisco bank will move to Oakland or anywhere else outside this city and county,” The Chronicle reported on April 22, 1906. “Not only that, but all of them will be open and doing business — and this quickly.”

A dramatically designed Wells Fargo Bank branch, 1962.

Photo: Karl H. Riek / Karl H. Riek 1962

The U.S. Mint building at Fifth and Mission streets, with $200 million coin in the vaults, emerged relatively unscathed. (It became such a symbol of strength that citizens who were worried about a second quake built a tent city in its shadows.) The bigger banks had similar good fortune. The only thing that kept them from distributing money in the days after the quake was the temperature of the steel vaults.

“Among the causes of delay is the danger in opening the vaults before they are entirely cool,” The Chronicle reported a few days after the fire ripped through town. “The (paper) contents of several vaults that passed through the fires in Boston and Chicago went up in smoke because of being opened too soon, and it is desired to avoid an additional catastrophe in this city.”

Bankers, even more than politicians, emerged as vocal leaders after the earthquake. While they were some of the richest men in town, they rolled up their sleeves and quickly went to work. And the tragedy forged in the bankers a fierce loyalty to San Francisco, one that influences the industry to this day.

Giannini was an especially vocal proponent of the rebuild. A former produce merchant who started his banking business on a plank resting over two barrels in working-class North Beach, he stayed in tune with the workers, and was humbled by their struggles.

Banking titan Isaias W. Hellman, great-grandfather of the late private equity investor and Hardly Strictly Bluegrass founder Warren Hellman, was another hero. More than 65 years old when the quake hit, the Wells Fargo Nevada Bank president lost his mansion on Broadway and his bank building, then responded by working 20-hour days out of his son-in-law’s home — bringing $2.5 million in gold to help with the rebuild.

“I would not know how to pass my time if I were to quit now,” Isaias Hellman said in 1912. “Work is a habit, a very good and necessary habit, and as long as a man has the strength to keep abreast of the times the best thing for his health and happiness is to keep in harness.”

The bankers were already battle-tested when the Great Depression hit. In some cases, they helped each other, and San Francisco rose out of the Depression more quickly than most cities. While banks in other cities were unable to keep up with the panicked withdrawals in 1933, the San Francisco banks (again led by Giannini, now running Bank of America) had more than enough gold. No major San Francisco bank was forced to close.

1911: The Bank of Italy's Clay-Montgomery office.

Photo: Chronicle file / Chronicle file photo 1911

After the Depression, the bigger banks continued to swallow the smaller banks. Most of the Gold Rush-era names — Pioche and Bayerque, Macondray & Co., and Paige, Bacon & Co. — are forgotten.

But Wells Fargo and Bank of America continued to grow; Wells bought Crocker National Bank in 1986. Both big banks built skyscrapers that were the tallest in San Francisco when completed — the Wells Fargo Building at 44 Montgomery St. in 1966 and the Bank of America Center at 555 California St. in 1969. Also worth noting are the Chinatown banks, which took from the Giannini model to serve a population that was being left out. Bank of Canton emerged after the 1906 earthquake, and at one point was the only Chinese bank in California.

San Francisco banks became technical innovators, among the first to experiment with automated teller machines and later online banking.

Bank of America, which moved its corporate offices to North Carolina in 1998, still has strong connections in the city. Wells Fargo remains headquartered in San Francisco, and built a museum to celebrate its history at 420 Montgomery St. A.P. Giannini in the Sunset District is one of San Francisco’s largest middle schools.

Bank of America founder Giannini still has a few lessons to teach — his 1949 obituary should be required reading for every modern executive in any field.

When Giannini died at age 79, his bank had grown to more than 500 branches and $5.7 billion in assets. But the man who built one of the biggest banking empires in U.S. history was reportedly worth only about $500,000.

Giannini’s only quote that ran in his Chronicle obituary was one to remember.

Peter Hartlaub is The San Francisco Chronicle’s pop culture critic and host of the podcast The Big Event. The Bay Area native has worked at The Chronicle since 2000, and was a Chronicle paperboy from 1982 to 1984. He reviews movies, television and comedy, covers entertainment, creates multimedia projects and writes the Our San Francisco local history column. The Big Event is recorded in The Chronicle’s basement archive. Hartlaub lives in Alameda.