Santa Clara, Calif. — Jim Harbaugh, in the signature outfit of khaki slacks and black pullover that has been his uniform the past four years, hustled off the field leading the way all by himself with the game ball cradled in his arms.

He gathered his team to announce he was leaving, but didn't tell the players where he's going next. After three straight trips to the NFC championship game and a Super Bowl near miss, Harbaugh and the Niners agreed to part ways following four seasons and the disappointment of a down year that began with Super Bowl hopes.

Harbaugh will not fulfill the final season of his $25 million, five-year contract coaching the 49ers that he signed in January 2011. The announcement came after Sunday's 20-17 win over the Arizona Cardinals that left the Niners at 8-8.

"It's been the time of my life," Harbaugh said. "Been a lot of great memories, great moments. ... It's been a tremendous four years, it's been a pleasure to work and serve for this organization. I feel great about what we accomplished."

Before he said his final goodbyes with hugs, handshakes and high-fives — even a greeting from Alex Rodriguez — there was one final "Who's got it better than us? No-body!"

"The last, 'Who's got it better than us?' I said it as loud as I could," said wide receiver Michael Crabtree, who could soon follow the San Francisco coach's departure.

Colin Kaepernick, the quarterback Harbaugh promoted in November 2012, threw a go-ahead 3-yard touchdown pass to Bruce Miller late in the third quarter and Frank Gore capped another 1,000-yard season with 144 yards on 25 carries.

Anquan Boldin caught a 76-yard TD pass and went over 1,000 yards receiving. Gore reached 1,000 yards rushing for the eighth time in 10 NFL seasons with the 49ers. The franchise's all-time rushing leader hopes to return to the only team he has known and the team has publicly expressed a mutual interest.