When the shovels hit the ground Thursday afternoon in Santa Clara, look to the sky. You might say that’s where it all began.

In autumn of 2006 as the 49ers were contemplating an exit from San Francisco to the South Bay, NFL Commissioner Roger Goodell visited the proposed stadium site next to Great America theme park. Goodell was met by Patricia Mahan, then serving as mayor for the city of 116,000.

Mahan did what any smart mayor would do: She took Goodell for a ride. Leading a delegation of 49ers and Santa Clara officials into the theme park, Mahan stepped with the commissioner onto the Star Tower, a revolving viewing deck that ascends 330 feet into the sky.

The motive wasn’t to give Goodell vertigo. Mahan wanted to show him the landscape from a better vantage point. See? That’s where the stadium would go. Notice all the parking spaces? Notice the light rail stop? The freeways? The Amtrak train stop? And over there is Intel headquarters. Down that road is Yahoo. On a clear day, you can see Google.

The commissioner asked a lot of questions, took it all in.

“At the end of the ride,” Mahan recalled this week, “he just looked at me and said, ‘This is a no-brainer.’ And I said, ‘I agree. It’s a perfect site. This is Silicon Valley central.’ “

Six years later, it’s also 49ers central. It was a long haul getting there. But when the groundbreaking ceremony for the NFL franchise’s new stadium begins at 5 p.m. Thursday, it will not just fulfill the vision of Mahan, now a Santa Clara City Council member, and others in the city who supported the idea. It will be a triumph for Jed York, the 49ers CEO who made the project his family mission and now will have the stadium as his lifelong legacy. And it will allow 49ers fans to start fantasizing about what they’ll experience when the stadium opens as soon as 2014.

Still, for those who have not followed the story closely, the question arises: How did we get here? How did the Bay Area’s eighth largest city become the home of Northern California’s most popular pro sports franchise? And why did the 49ers even leave San Francisco?

To answer those questions, you start in December of 2003. Kevin Moore, a Santa Clara native and relentless civic booster who would soon be elected to the City Council, sent a letter to 49ers owners Denise DeBartolo York and John York.

Moore had heard that the team was getting nowhere in its stadium discussions with San Francisco. He wondered why the 49ers didn’t consider a project on one of the huge Great America parking lots across from the team’s practice facility and offices.

Early in 2004, Moore and John York met at the 49ers headquarters building on Centennial Drive. York agreed to keep Santa Clara as a backup in case the San Francisco situation continued to deteriorate, which it did under newly-elected Mayor Gavin Newsom. By the summer of 2006, Jed York had left his job on Wall Street and been named the 49ers’ director of strategic planning, in charge of the stadium pursuit. He gradually became convinced San Francisco was a dead end.

“You just kept hitting a wall,” York said. “And we couldn’t find a way to get around that wall. You’re always going to run into a wall on a project like this. But usually, you can find a way around it. We couldn’t in this case.”

Here was the problem: The 49ers wanted to build their new stadium on the Candlestick Park property. Newsom kept pushing for a large, mixed-use redevelopment package — complete with a massive housing component — at the nearby abandoned Hunters Point shipyard. Transportation to the site was a problem, even worse than Candlestick. Also, the site required a toxic cleanup.

“It just wasn’t going to work,” York said. “It doesn’t mean a housing project wouldn’t work there. It doesn’t mean a stadium project wouldn’t work there. But it wasn’t going to work together.”

After investigating about 80 potential Bay Area sites, York identified Santa Clara as the best and most viable option. His father and mother agreed. Goodell gave his theme-park-ride seal of approval. Newsom’s administration was not returning phone calls promptly. The plug was pulled on San Francisco, to some outrage. In early 2007, machinery was set in motion for Santa Clara.

Team negotiators and city executives hammered out tentative numbers. The Santa Clara City Council approved the general terms, which required the 49ers to either pay or borrow money for 90 percent or more of the stadium cost. Then came a ballot measure in 2010 to gain residents’ approval.

That led to the most remarkable moments in the entire process. The 49ers, represented mostly by Jed York and his father, scheduled a series of neighborhood block meetings. Sitting down in living rooms and community centers, they answered questions about the team’s plans. When one Santa Clara homeowner said he was a Dallas Cowboys’ fan and would never vote for a 49ers stadium, Jed took out his cellphone and called Cowboys’ owner Jerry Jones, who spoke to the homeowner and lobbied for a “yes” vote.

In retrospect, Jed York said, the response he received from Santa Clara residents at those meetings was crucial in another way.

“I think that’s when I knew there was a real possibility this could happen,” he said.

Opponents of the stadium plan surfaced in Santa Clara with their financial arguments. But the 49ers bankrolled a massive campaign in 2010 that resulted in a “yes” vote for the stadium. Jed York went to work on finding money for construction. New Santa Clara Mayor Jamie Matthews, Mahan’s successor, picked up the ball and kept pushing it downfield. A dispute with Great America’s owners was settled. Luxury suites and seat licenses went on sale. A construction contract was signed with big bonuses if the stadium is ready for the 2014 season.

And now, shovels at 5 o’clock.

“When I look back, it’s kind of a miracle,” said Moore, an inveterate optimist who can now admit that dealing with stadium politics was the toughest thing he’d been through.

“I’m just happy,” Mahan said. “I’m happy the 49ers are going to be in the South Bay, happy they are going to stay in the Bay Area, happy they will be playing in a place their fans will enjoy, happy it’s in Santa Clara. Happy about it all.”

The other day, Moore reminisced about Goodell’s visit in 2006 and laughed. That morning, in a welcoming effort, Moore had driven to the Santa Clara University bookstore and put down his own credit card to purchase a SCU rain jacket, then had his mother wrap it up in a gift basket for the NFL commissioner. Imagine a big-city politician doing that. Moore is a little sheepish about it now. But thinking about that trip up the Star Tower, he believes the personal touch from a smaller city made a difference.

“I had no doubt the mayor’s charm would make it work for us,” said Moore. “I remember looking over at her and the commissioner as they were looking out the tower windows. They were smiling a lot. I knew that was a good thing.”

Six years later, those smiles have led to shovels. And considering what will happen on the site over the next 50 years or so, including the likelihood of Super Bowls — well, the ride is just beginning.

Otto Warmbier was arrested in January 2016 at the end of a brief tourist visit to North Korea. He had been medically evacuated and was being treated at the University of Cincinnati Medical Center when he died at age 22.