All things considered, Alex Smith's career in San Francisco appears to be reaching a fairy-tale ending. The 49ers will almost certainly complete a trade for him in two weeks, possibly to a team run by a quarterback-whisperer of a coach.

For a No. 1 draft pick, the winner of a 2011 playoff shootout with Drew Brees and the owner of 2012's top completion percentage, the farewell will count as pure, bitter rejection. For the real Alex Smith, not the one-dimensional profile, there will be a happier conclusion than anyone could have imagined for most of his 49ers tenure.

Fans booed him and chanted for his backup during a nationally televised game. Online commenters dubbed him Al-excuses, not because of his attitude, but because his  supporters always shifted the blame for his failures.

He played for one head coach who casually called him "meek'' (Mike Singletary) and an offensive coordinator who called him "anal'' (Jimmy Raye), trying to spin it as a compliment.

By the end of the 2010 season, after the trek through Singletary melodrama to his free-agency year, he ached to leave. Polite as ever, he feigned uncertainty. But in one unguarded moment abandoned demurrals about whether he'd consider returning to the 49ers. "Are you being serious?'' he said when Bay Area News Group columnist Monte Poole asked if he'd consider returning. "Uh, no.''

That could have been his San Francisco valedictory, a perfect summary of his six seasons with the 49ers, from every perspective. "Uh, no.''

Instead he will leave with the Bay Area's gratitude. Jim Harbaugh saw something in Smith and built it up. We can debate whether he became simply an exceptional game manager or a winner, damn the style points. We can say he was no Manning, no Rodgers, Brady or Brees. But he wasn't a lost cause. He wasn't the same old Al-excuses.

He'll leave because he wasn't Colin Kaepernick, either. Smith became an object of pity when he lost his job in midseason. He yielded first to a concussion, then to a transformative quarterback whom Harbaugh had quietly designated as the heir -- not so much to Smith as to Joe Montana and Steve Young.

"I feel like the only thing I did to lose my job was get a concussion,'' Smith said shortly after the switch became final. Then he shut up, as he had many times before, under coaches who never helped him thrive the way Harbaugh did.

The sympathy for him was misplaced. The nature of the NFL guarantees cruel losses for players who did nothing wrong aside from choosing a vicious profession. They lose their jobs, their knees, their cognitive function.

In the big picture, the bad break of having Kaepernick in the wings balanced by the fact that, as a No. 1 pick, Smith routinely got extra chances to prove himself.

"They usually get rid of those quarterbacks,'' teammate Carlos Rogers told KNBR Radio. "And this organization, this team has stuck with Alex throughout thick and thin.''

For years, the 49ers' constant turnover of offensive coordinators -- seven in Smith's first seven seasons -- reigned as the premier explanation for his failure to thrive. The theory made sense; no young quarterback becomes a star amid that kind of chaos.

But for four seasons, the 49ers had an undrafted quarterback on their roster who endured the same chaos that Smith did, with additional disadvantages. Shaun Hill began most of those years  buried on the depth chart, getting few if any reps with the first team. Yet he compiled a 10-6 record when he got the chance to start, and did it in seasons when the 49ers couldn't breach .500. He excelled as a game manager but also as a master of the broken play. He was no Manning, Brees, etc., But working with the liabilities used to defend Smith, he succeeded more.

Hill, however, lacked patrons in the front office, while Smith kept working for the general manager who had helped draft him at No. 1. The 49ers gave up on Hill, plus his exotic proclivity for winning, far too quickly in 2009. He had one and a half bad games in October, and the team abandoned him for good. He was traded in the offseason to Detroit.

The two of them, Hill and Smith, became good friends, a testament to one of Smith's skills: He was an exceptional teammate.

You can't measure that statistically, and most players figure out how to fit into a locker room of disparate personalities. But Smith had a way of winning people over, even if they didn't have faith in his abilities. At the end of the 2012 season, when Kaepernick had clearly established himself as the starter, several 49ers balked at talking with the media about how he had upgraded the offense. They didn't want to say anything that could somehow reflect poorly on Smith. They were too fond of him to let that happen.

He had taken charge of informal workouts during the 2011 lockout, even though he had no contract with the team. The media labeled the workouts "Camp Alex.''

Only months after he had said, "Uh, no,'' he had succumbed to Harbaugh's recruiting tactics, which included giving him a playbook during a brief break in the lockout, even though Smith remained a free agent and could have taken that knowledge to another team if he had signed elsewhere, and getting permission from the lockout police to send flowers to Smith's wife after the birth of their first child.

That courtship, plus the confidence Smith gained as he ran the camps, signaled the shift to a fairy tale. Whenever he beamed after a win that year, when Harbaugh ruffled his hair affectionately after a touchdown, when the fans howled their devotion after the Saints game and before the NFC title game, the sappiness quotient soared.

It didn't have to add up to "happily ever after.'' Nobody, thinking it through clearly, would have expected that.

But it represented the impossible. I never thought Smith could manage the transformation as a 49er. I was certain that he needed a change, some time as a backup to observe and learn from a valued starter. Otherwise, he would hiccup in every big moment and play well only when it didn't matter. I remember saying that on a radio show in the 2011 preseason, still incredulous that his "Uh, no'' had been forgotten.

But Smith had won me over in one way. I told the radio show host that Smith was the kind of person who made me wish for something columnists usually hate. I wanted to be wrong.

By the end of 2011, it didn't matter that he still had substantial limitations, or that other teams seemed remarkably uninterested during his second go-round with free agency or even that the 49ers kicked the tires on Peyton Manning.

He had changed how people saw him. He proved Roddy White wrong. The Falcons receiver had tweeted surprise when the 49ers brought Smith back for 2011: "2 coaches have been fired for that mans performance.''

He had put miles between himself and the insinuations about his toughness. Even his first head coach, Mike Nolan, the man who chose Smith because he had a lighter personality than Aaron Rodgers, had implied that Smith was reluctant to play through a dislocated shoulder. That prompted the kind of boldness coaches hate. Smith told a reporter that Nolan was trying to undermine him in the locker room.

He won't be leaving with all that noise in his head. He will go with memories of throwing out a first pitch at a Giants playoff game, of driving a car in their World Series victory parade, just like Harbaugh, of becoming  a welcome part of the city's culture.

In his new home, Smith may struggle without Harbaugh as his mentor, and without all the teammates he has known so many years. Or he may rediscover some arm strength that disappeared after two shoulder surgeries and has not been cultivated since. We'll find out if the checkdown is his soulmate or just his partner in an arranged marriage blessed by coaches leery of seeing what else he can do.

But we know now that he has a capacity to surprise, to rewrite stories set in stone. San Francisco should wave goodbye in wonder.