Pryce ranks third in sacks among active players but has only one tackle this season. The 35-year-old has not started any of Baltimore's three games.
Harbaugh said there's a "high possibility" that Pryce will return.
"You've got roster issues that you deal with. It's not something we wanted to do," Harbaugh said of the move. "Trevor is a big part of what we're doing here, and we anticipate getting him back. It's just what we had to do for now."
Hamlin has seen action in 100 games, including two for the Ravens this season, totaling 565 tackles, 14 interceptions and five sacks during his eight-year career.
"We said before we wanted him back. He figures into our plans the rest of the year," Harbaugh said.
Harbaugh insisted that Hamlin was simply a better fit on the roster for this week.
"We're going to put the 45 best guys out there," he said. "I would rather have Trevor here this week playing, but we're not able to do that. We just have a numbers situation."
Pryce's locker had not been cleared out.
"It's totally different not having him here," said offensive tackle Marshal Yanda, whose locker is next to Pryce's. "I guess that's part of the business."