Marlins right-hander Dan Straily hit Longoria in the fourth inning. Longoria stayed in the game briefly to run before being replaced in the field.
A decision on whether surgery is required is expected in the next couple of days.
"Obviously the goal is to decide something as soon as possible and then get going in the right direction, whether that's put a cast on it and just let it sit or have some sort of surgery and go that route,'' Longoria said.
Manager Bruce Bochy made the announcement on the injury after his team's 6-3, 16-inning win.
"That's a tough break for us," said Bochy, who added that Longoria will get a second opinion when the team returns to San Francisco.
It's the same injury teammate Madison Bumgarner suffered during spring training. He returned to the rotation June 5.
"It wasn't my legs,'' Longoria said. "I just hate coming out of the game right away. I've always thought it looked bad. I knew right away that it didn't feel right, but I just figured I could run and in the meanwhile let (Alen Hanson) get loose and come into the game.''
Longoria is hitting .246 with 10 home runs and 34 RBIs in his first season with the Giants.
"It's a tough loss,'' Pablo Sandoval said. "I don't know how many days he's going to be out, but we're going to miss the guy. He's a great hitter, great defensive player, and a great teammate. I hope he recovers well and comes back to help us get to the postseason.''
The Associated Press contributed to this report.