At the end of last week's "The Office," the next-to-last episode featuring Steve Carell as Michael Scott, the office staff came together to serenade Michael with their own version of "Seasons of Love" from "Rent," lovingly listing all the minutes he worked at Dunder-Mifflin, and then all the minutes they in turn spent in his pointless meetings, listening to his corny jokes, reading his e-mail forwards, etc.

It was an extraordinary moment in the life of the series. It was sweet and clever and incredibly touching (Carell was so obviously choked up that you could easily take his reaction as that of the actor or character). It was also the exact perfect gift the staff could give Michael, who had spent the better part of seasons trying to drag his employees kicking and screaming into his fantasies of the office as both a surrogate family and a place where he could sing, dance, tell jokes, do characters and generally have his genius for performing acknowledged.

And that was the most extraordinary thing at all. Because if you go back to the early days of "The Office," it is hard to imagine a circumstance under which Jim, Pam, Oscar, Ryan and the rest of the gang would have not only done this, but done this out of genuine affection for Michael and sadness that he was leaving them.

At the beginning of "The Office," Michael was so scorned by the staff - and rightly so, given his insensitivity, his offensive sense of humor and his completely tone-deafness of most social situations - that he had to buy himself a "World's Best Boss" mug to celebrate what he wanted his standing to be.  He leaves (Carell's extra-long final episode airs on NBC tomorrow night at 9) with something far better than that mug: with the knowledge that these people really do like him, and they get him, and they can play his reindeer games from time to time because of how much they matter to him.

It's kind of incredible to think on that transformation, and how gradually and mostly naturally the show pulled it off.

The beginning was very bumpy, as the series' pilot was a pretty strict copy of the first episode of the original British series. What had been funny and ultimately harmless coming out of the mouth of Ricky Gervais' David Brent suddenly seemed cruel from Carell. I remember chatting with the show's executive producer, Greg Daniels, at an NBC press tour event the winter before the debut, and when I said Carell came off as really menacing in the scene where Michael pretends to fire Pam as a practical joke, he literally took a step back from me and said, "Well, that's not good!" 

But Daniels and company stopped using the British scripts after that. More importantly, they started tailoring the character specifically for Carell. (Daniels has said that it helped the writers enormously to see their star in "The 40-Year-Old Virgin" in the summer between the first two seasons, as it helped them figure out how to put a Carell character in awkward situations without making the tension unbearable.) Michael and David Brent still shared a love of performing, and a deluded belief in their own gifts in that area (Gervais had a priceless cameo as Brent earlier this season, where he and Michael bonded over their shared love of ethnic caricature), but he became his own man. Where David was predatory (or tried to be), Michael was an overgrown child, still trapped as the lonely 11-year-old boy who watched too much TV and dreamed of one day having lots of children,  because they would have no choice but to be his friend.

And bit by bit, Daniels and the other writers began taking Michael on the long, winding, hilarious road from barely-tolerated nuisance to the kind of guy whom everyone in that office will speak of fondly for years to come as they recall all the good, bad and ridiculous things he did.

And I have a run-down of the crucial Michael evolutionary episodes in gallery form. Enjoy.

Alan Sepinwall may be reached at sepinwall@hitfix.com