SANTA CLARA, Calif. (AP) — The San Francisco 49ers have acquired star running back Christian McCaffrey from the Carolina Panthers for a haul of draft picks.

The Panthers on Thursday night announced the deal that sends McCaffrey back to the Bay Area where he starred in college at Stanford. They said it will be finalized when McCaffrey passes a physical.

The Panthers will receive picks in the second, third and fourth rounds of the 2023 draft, as well as a fifth-rounder in 2024, according to a person familiar with the terms. The person spoke on condition of anonymity because the terms were not announced.

Carolina had been seeking a first-round pick, but San Francisco had already dealt its 2023 first-round pick in a deal to draft Trey Lance last year.

“I’m forever grateful for all of people who helped make these last 5 1/2 years so special for me,” McCaffrey tweeted Friday morning. “Thank you from the bottom of my heart. Carolina, I will always love you.”

McCaffrey joins a talented group of playmakers in San Francisco with versatile receiver Deebo Samuel, star tight end George Kittle and receiver Brandon Aiyuk.

But the Niners (3-3) were not as strong at running back with starter Elijah Mitchell out with a knee injury. McCaffrey provides coach Kyle Shanahan with one of the best as both a runner and receiver, adding another element to San Francisco’s offense.

McCaffrey has a $990,000 salary this year after Carolina reworked his contract, making him an easy fit under the salary cap. He is owed about $36 million over the next three years, but none of that is guaranteed.

McCaffrey becomes the second skill position player to be traded this week by the Panthers (1-5) since coach Matt Rhule was fired on Oct. 10. Carolina sent wide receiver Robbie Anderson to the Arizona Cardinals on Monday for two future late-round draft picks.

The trade leaves the already depleted Panthers offense extremely thin at running back with D’Onta Foreman and Chuba Hubbard expected to compete for the starting job and Raheem Blackshear potentially in the mix for more work.

The 26-year-old McCaffrey is considered one of the most versatile running backs in the league when healthy because of his ability as a runner, receiver and blocker.

He missed 23 games over the previous two seasons due to injuries, but has played in all six games this season and is fourth in the NFL in yards from scrimmage (607) despite playing for the league’s 32nd-ranked offense. He and Cleveland Browns running back Nick Chubb are the only players in the league to have five games this year with at least 100 yards from scrimmage.

McCaffrey has 7,272 yards from scrimmage — 3,980 rushing and 3,292 receiving — and has scored 50 touchdowns since coming into the league as the eighth overall draft pick in 2017.

McCaffrey’s best season came in 2019 when he had 1,387 yards rushing and 1,005 yards receiving, making him only the third player in NFL history to eclipse 1,000 yards in both categories. He also had 19 touchdowns that season and was named All-Pro.

McCaffrey’s father, Ed, won a Super Bowl with the 49ers in the 1994 season and won two more titles in Denver with Shanahan’s father, Mike, as his head coach.

___

AP Sports Writer Steve Reed contributed to this report

___

AP NFL: https://apnews.com/hub/nfl and https://twitter.com/AP_NFL