The San Francisco 49ers and wide receiver Michael Crabtree agreed to a six-year contract in the wee hours Wednesday morning after several months of difficult negotiations.