Foster was carted off the field and to the locker room with 3:33 left in the first quarter of the 49ers' 23-3 loss to Carolina at Levi's Stadium.
The 49ers initially feared he broke his right tibia, but the X-ray was negative. Foster limped back to the sideline early in the second quarter and missed the rest of the game with what the 49ers are calling an ankle injury.
"It was hurting, but as the game went on, it starting getting looser and better," said Foster, a first-round pick out of Alabama, who started in his debut.
Foster was hurt while tackling Carolina rookie running back Christian McCaffrey. Panthers offensive tackle Matt Kalil blocked Foster from the side, and the linebacker landed awkwardly, with his leg bent back.
"It was more optimistic than it (initially) looked," 49ers coach Kyle Shanahan said of Foster's injury. "Still got to do more tests and stuff. He couldn't return. Some type of ankle injury. We're going to have to look more into it. It was definitely better than it seemed out there."
Foster had three tackles, including one for a loss, and broke up a pass in his limited action.
"I felt great," Foster said. "It's sad that I had a nick in the ankle."
--McCaffrey made his NFL debut just a few miles southwest of where he went to college at Stanford, and he had to feel at home getting a heavy workload. McCaffrey carried 13 times for 47 yards, with a long run of 11 yards, and lost one fumble. He caught a team-high five passes for 38 yards, including a 16-yarder. He also returned three punts for 7 yards.
McCaffrey had some of his best runs and catches after losing a fumble early in the fourth quarter when 49ers cornerback Rashard Robinson stripped the ball away and recovered at Carolina's 31-yard line.
"Just keep my head up," McCaffrey said. "It happens, but it can't happen. I tried to cover it up, but the guy made a good play. Coming back, you've got to respond."
McCaffrey was tackled once in the second quarter by 49ers rookie defensive end Solomon Thomas, his former Stanford teammate and a fellow first-round draft pick.
"We're really good friends off the field, but on the field we're trying to compete," McCaffrey said.
--Carolina starting cornerbacks James Bradberry and Daryl Worley both missed some time early in the second half because of muscle cramps and had to receive fluids through IVs.
"They both cramped up on the same play," Panthers coach Ron Rivera said. "So I told (offensive coordinator) Mike (Shula), 'We're going to need a long drive. You've got to grind it out best you can.' And low and behold, he was able to chill most of the third quarter."
The Panthers had an 11-play, 66-yard drive for a field goal that used 6:53 in the quarter.