There were death threats against him, police at his home and Fifa officials seized his laptop and cellphone to probe for match-fixing.
Four months on, he has broken his silence on the game - and is preparing for his first international tournament since Brazil.
"It wasn't at the stage where bullets had been sent through the post or anything but it was tough," O'Leary says. "Fans are passionate but sometimes you think, well, just hang on."
O'Leary disallowed a goal which cost Bosnia-Herzegovina their group qualifying match against Nigeria - and sparked fury from the debutante country's fans.
Football's governing body Fifa paid no heed to the petition and O'Leary stayed in Brazil.
But that meant the father-of-two was thousands of miles away from wife Rachelle and sons aged 7 and 5 as angry Bosnians made threats against his life and his home.
New Zealand police visited the family to make sure they were safe and to give them protocols should anything happen.
"I knew to make sure my family was safe, that's the most important thing for me.
"We still took it seriously and the police were involved with just making sure that, while I wasn't here, home and work and everyone knew what was happening and there were protocols to follow if something did rear its ugly head."
The 42-year-old was in touch with his family throughout the tournament.
"We liaised with Rachelle and the boys and had a contingency with the police should anything turn pear-shaped." There was more to deal with for O'Leary in Brazil. A photograph appearing to show him celebrating with the Nigeria goalkeeper was fuel to the fire. So enraged were the conspiracy theorists that Fifa sent officials to take his laptop and cellphone as they probed the possibility of cheating. The technology was taken away for 24 hours until the officials were satisfied.
"Just because of match-fixing or any other allegations like that, that's how serious they take it," O'Leary says. "But they came back and said 'look, we don't have a problem with you'."
NZ Football referee development officer Ken Wallace says the vast majority of referees are never targeted by upset fans, and counts O'Leary's experience as "exceptional".
"I had a long international career and I certainly never experienced something like that, and I don't believe many other referees have either. That was a very exceptional thing.
"I think most of the time when you referee a game, the players and the fans are really good and you just go out there and referee the game. Ninety-nine per cent of the time it's fine, but you get a bit of stick no matter what job you do."
A dejected Edin Dzeko, striker for Bosnia-Herzegovina. Photo / AP
As one of New Zealand's top referees, it was a dream come true to head to the Brazil World Cup, the 20th four-yearly tournament since its humble beginnings in Uruguay in 1930.
Many countries send full-time, professional referees to the event but, like all New Zealand refs, O'Leary juggles his hobby with a full-time job as head of science at the Northland school.
He had been selected to ref after more than 20 years with the whistle, and more than three years of training for the tournament, which he described as "awesome" and "surreal".
"We flew into Porto Alegre and just at the hotel was [All Whites coach] Ricky Herbert and then sitting down to dinner, Arsenal manager Arsene Wenger walks in with France legend Franz Beckenbauer.
"It was like, 'Holy sheez, this is football royalty and it's all in touching distance'."
O'Leary's first role was as the fourth official in the match between France and Honduras - the first game in the tournament's history to use goal-line technology. "It was amazing to be involved with that bit of history," he says.
And then he got the call he had been waiting for - "the high point in any referee's career" - when he was selected as the on-field ref for the crucial clash between Nigeria and Bosnia-Herzegovina.
World Cup debutantes Bosnia-Herzegovina had just come off a positive display in a narrow loss to tournament favourites Argentina, and were confident of overcoming the Africans.
That optimism seemed to be realised when striker Edin Dzeko fired into the back of the net after 21 minutes. But to the dismay of Dzeko, his teammates and the jubilant fans, the goal was ruled offside by O'Leary's assistant and upheld by O'Leary.
Television replays showed that Dzeko was clearly onside.
"That's an obvious error," O'Leary accepts. "The assistant referee at the time said it was offside, put his flag up and I said, 'Thank you very much, offside'.
"I didn't make the call. However, as the referee, I'm in charge. I'm responsible and I carry the can.
"If I was in a better position and had seen what had happened, I would have been able to overrule him. But I wasn't in a better position so I couldn't."
Peter O'Leary was snapped congratulating Nigeria's goalkeeper. Photo AP
There's an old saying in football that you have to be mad to be a goalkeeper. If that's true, you must be a raving lunatic to be a referee. At grassroots level in New Zealand, 20,000 registered referees turn up on cold, wet winter days to officiate a game of 22 men colliding aggressively with each other. They are frequently abused by players and fans alike.
That pressure is amplified in the white-hot atmosphere of the biggest sporting event on the planet, especially when officiating in the centre of the Arena Pantanal stadium in Cuiaba in front of more than 40,000 highly charged fans.
The Bosnia-Herzegovina fans reacted furiously at the disallowed goal and they felt further cheated when Nigeria scored 10 minutes later.
The management bench erupted, believing their team should have had a free kick in the lead-up to the goal.
O'Leary stands by his decision to deny a free kick, and says Fifa officials told him after the game that the call had been correct.
"The offside they were not happy with because it was obviously wrong. The goal they said, 'this is nothing, this is fine'."
Striker Dzeko had a chance to level the score towards the end but fluffed his lines, and the game finished with a Nigerian victory.
And, of course, no one remembers the striker's mistake. But they remember O'Leary's - and they remember the photograph.
O'Leary had never met the goalkeeper and said they had been congratulating each other on taking part in a World Cup game.
"The Nigerian goalkeeper is a character ... with a sunny disposition.
"At the end of our game he had the ball, I went and got the ball off him. He said congratulations, put his arm around me and I put my arm around him.
"While we were doing that, the fourth official said something in my ear and that made me laugh."
But Bosnia-Herzegovina's fans and players were outraged. Dzeko slammed O'Leary's performance as "shameful" and said he "should be going home, too.
"He changed the game. That's why we lost. It was obviously a foul on our captain and before, when I scored the goal, it was never offside."
Coach Safet Susic said his side had been robbed. "I was told there was no offside but it's not the first or last time a referee has made a bad decision at this World Cup, and it won't be the last."
O'Leary has not been put off refereeing and is preparing for the Asian Cup in January, his first international tournament since the World Cup. He takes comfort in the support he received from his school, family and the football community at large.
"Some of the letters of support were amazing. [Former rugby referee] Bryce Lawrence sent me a wonderful email of support saying, 'Hey, I know what you're going through'. And from students, past and present. Family and friends kept me grounded," he says.
"It has been tough. It makes it difficult, but also football's just a game and it's important to remember that."
And he insists he can handle the pressure, as exam time at high school is more stressful than tens of thousands of fans calling for his head. "Football is a game compared to preparing students for their futures."
Football referees at risk
• 2004: English tabloids angry at Swiss ref Urs Meier denying England a winning goal against Portugal publish his personal details leading to thousands of abusive and threatening letters.
• 2005: Top Swedish ref Anders Frisk retires after death threats to his family from Chelsea fans over a Champions League defeat.
• 2013: US ref Ricardo Portillo, 46, dies after being attacked by a player who he had booked.
• 2014: Brazilian football referee is beheaded by angry fans after he fatally stabbed a player during a brawl.
• October: A pipe bomb explodes outside referees' headquarters in Cyprus, and a fire bomb is thrown at the home of a referee.