Harbaugh will replace fired coach Mike Singletary. He also had been considering an offer from Stanford to stay put.
Harbaugh decided to make the jump to the pros even though San Francisco has missed the playoffs for eight straight seasons and Orange Bowl MVP quarterback Andrew Luck decided to remain at Stanford for another season.
"I can feel the enthusiasm coursing through my veins right now," Harbaugh said. "I accept this competitive challenge willingly."
The Cardinal (12-1) finished with a school-record 12 wins following a 40-12 victory over Virginia Tech in the Orange Bowl.
The 47-year-old Harbaugh went 58-27 overall as a college coach and 29-21 in four seasons at Stanford. He took over a 1-11 team when he was hired in December 2006 and quickly turned the program back into a winner and bowl contender.
The Associated Press contributed to this report.