In the aftermath of the Bills’ first Super Bowl loss in January 1991, coach Marv Levy leaned on his master’s degree in English history from Harvard to offer inspiration to his devastated team.

The source was a few lines from an old ballad celebrating Sir Andrew Barton, a 16th century Scottish privateer.

Said Levy: “I posted a poem that I remembered: Fight on my men, Sir Andrew said. A little I’m hurt, but not yet slain. I’ll just lie and bleed a while. Then I’ll rise and fight again.”

Sound familiar, 49ers fans? A day after the 49ers lost 20-17 in overtime to the Giants in the 2011 NFC Championship Game, Jim Harbaugh struck the same literary note to characterize the emotional state of his team: “Hurt but not slain, lay down and bleed awhile, then we’ll rise and fight again.’”

Unfortunately for Harbaugh, who has crammed a career’s worth of big-game heartache into his first three seasons with the 49ers, there have been other occasions to reference Sir Andrew.

Since 2011, the 49ers have lost two NFC title games and a Super Bowl by an average of four points, with each setback ending in devastating fashion.

The overtime loss to the Giants featured two late-game fumbles by punt returner Kyle Williams. That was followed by a 34-31 Super Bowl loss to the Ravens which featured three straight incompletions from Baltimore’s five-yard line in the final minute. Finally, last month, the 49ers fell to Seattle, 23-17, in the NFC title game when Colin Kaepernick was intercepted in the end zone with 22 seconds left.

The string of excruciating endings begs some questions: What kind of emotional toll can such a string of near-misses have on a team? Can doubt or a fatalistic mindset invade the locker room? Is there a limit on how many times a continually crushed team can rise and fight again?

Levy, 88, is something of an expert on the topic. The Bills lost four straight Super Bowls from 1990-93 and the Hall-of-Fame coach monitored his team’s emotional psyche as it pursued what he termed their “impossible dream.”

After their final Super Bowl loss, the Bills had two losing seasons and managed one playoff win in Levy’s final four years. In reflection, though, Levy dismisses the idea that Buffalo’s run ended because of it was emotionally spent. Rather, he points to the Bills’ string of wild success – no other team has won four straight conference championships – as evidence of their resilience and heart.

Levy, who, like Harbaugh, has a deep admiration for Winston Churchill, believes his teams embodied a famous quote from the former British prime minister: “If you’re going through hell, keep going.”

Said Levy: “As far as becoming so morose that you go into some kind of funk? No. Never. That is a loser that does that. A guy that’s a winner finds his way to bounce back. There’s one way to never lose a championship game: Don’t get there.”

That said, Levy acknowledged each big-game loss was followed by a difficult mourning period where “you cry and pound your pillow and mattress at night.”

Niners tight end Vernon Davis knows that emotion all too well. Last month, a day after losing at Seattle, Davis conceded it was “brutal” to keep coming up short of a Super Bowl title.

“It’s very tough to handle emotionally,” Davis said. “We’ve been down this road before, and we’ve been in this same spot where we didn’t quite pull it off, didn’t work out in our favor. This is a tough time. You just have to be strong mentally, you can’t let it get the best of you … I don’t think we can keep getting to this spot and keep losing. It’s just not fun. It’s not good. It sucks.”

The 49ers’ three-year run is also similar to that of the Eagles, who lost three straight NFC championship games followed by a Super Bowl defeat from 2001-04.

Former running back Brian Westbrook, who played with Eagles from 2002-09, lost three conference title games, a Super Bowl, a divisional-playoff game and a wild-card game during his close-but-not-quite tenure in Philadelphia.

But Westbrook insists a here-we-go-again-mentality didn’t take hold of those teams.

“Obviously, different players experience different things, but on all of our teams we had no doubt that we could get back there and win it because we had the same elements,” Westbroook said. “We had similar core group of guys. We believed we just needed another opportunity, and that came with the next season.

“Our mindset was exactly what it had to be: ‘I’m going to put all on the line again no matter what happened last year.’”

CBS analyst Steve Tasker, a seven-time Pro Bowl special-teams player with the Bills from 1986-97, notes the 49ers are built to keep taking Super Bowl runs. They have 18 of their 22 starters under contract for 2014, including all eight Pro Bowl selections and a gifted, still-developing 26-year-old quarterback in Kaepernick.

That is, they will have the core intact from teams that conceivably could have won Super Bowls the past three seasons, if not for ill-timed turnovers or incompletions.

“You can’t think just because it’s happened to you, like it’s happened to the 49ers the last three years, that something’s wrong with your team,” Tasker said. “You have to realize that stuff happens. You are good enough and just keep on keeping on. You are good enough to get back to the championship game.

“You are good enough to get back to the Super Bowl. Don’t think you have to change something drastically so that you can win, because you’re good enough to win now. The question is can you stay there and come back next year and give it the same kind of effort?”

And Tasker is certain they will. Both Tasker and Westbrook echoed Levy in noting the makeup of NFL players, who often rise to the highest level of their sport thanks to their resilience and unwavering self-belief.

Levy joked those same intangibles aren’t always evident in fans, who could benefit from the inspiration gained from a certain Scottish ballad.

“After our second Super Bowl loss, I was on this Monday night call-in show and one of our fans said ‘Coach, please, don’t go back next year. I can’t stand it. I can’t go to work Monday when we lose’ and so on,” Levy said. “I said ‘Sir, I understand your anguish. I share it. But I’m glad you’re not on my team.”