When Manchester United manager David Moyes shakes hands with his City counterpart Manuel Pellegrini at pitchside before Sunday’s Manchester derby, he could be forgiven for thinking, somewhere in the back of his mind: “I owe you.”

After all, this may be the first derby encounter since the pair took the respective reins at United and City but they have met before in a match which, for all the hype swirling around Manchester this weekend, had considerably more at stake and delivered a controversy that still rankles with Moyes to this day.

It was the Champions League third qualifying round tie between Moyes’s Everton and Pellegrini’s Villarreal in August 2005. For both managers, the prize was a place in the group stage for the first time, and with it a £20m windfall. In Moyes’s case, it was the chance to build on the Merseyside club’s fourth-placed finish of 2004/05 – the best of his Goodison reign – but instead it was Pellegrini who prevailed, albeit only after referee Pierluigi Collina disallowed a perfectly legitimate Duncan Ferguson header which would have levelled the aggregate scores in the second leg in Spain.

For Moyes, the controversial circumstances left a bitter aftertaste still evident when he was asked about his past Champions League experience last week. “I still think it was the biggest turning point in my Everton history,” he said, as he reflected on how “that pot of money” could have propelled Everton forward. Remembering Collina’s baffling call in the Italian’s final match before retiring, he even opened the door to conspiracy theorists when speculating that Uefa “could not have afforded to have had five English teams in the main draw”.

That was the summer Liverpool, Champions League winners in Istanbul but fifth in the Premier League, were handed a place in the first qualifying round. Come the draw for the third qualifying round, Mikel Arteta held his head in his hands when Everton were pitted against Villarreal. “We knew it was a worst possible scenario,” recalls David Weir, the former Everton defender.

Yet Weir, now manager of Sheffield United, adds that Moyes had Everton “well versed” to face Pellegrini’s side. “They played with two deep-lying midfielders probably before its time. Marcos Senna was one of them. [Juan Roman] Riquelme was a big piece of the jigsaw too – he could basically go where he wanted, do what he wanted.”

Pellegrini had taken charge of Villarreal the previous summer – his first job in Europe – yet immediately led them to the Uefa Cup quarter-finals as well as an unprecedented third place in La Liga. As with the Malaga side he took to the Champions League quarter-finals last season, Pellegrini was adept at instilling belief in his players and his principal demands, says Javi Venta, the former Villarreal defender now at Brentford, were the same regardless of the opposition – “trying to keep hold of the ball, pass the ball and create some chances” – though they knew Moyes’s men would provide a different kind of test. “We had the chance to get into the Champions League for the first time but we knew it was going to be hard. Everton were a strong, direct team, they got the ball down the wings and we had to cope with that.”

They did more than cope in a 2-1 first-leg victory at Goodison Park, Luciano Figueroa and Josico scoring either side of James Beattie in the first half. Kevin Kilbane, the Everton midfielder, believes that “nerves, expectation got the better of the team” that evening but the Merseysiders were more like themselves in the second leg at Villarreal’s compact El Madrigal ground.

For Pellegrini, the prize must have felt ever closer when Villarreal took the lead after 21 minutes with a fortuitous Juan Pablo Sorin goal. “A shot hit me and wrong-footed the goalkeeper,” Weir remembers. However, Everton came back into the game in the second period as Kilbane recalls: “We said to ourselves, ‘If we’re going to go out, we’re going to go out fighting’ and we played really well.”

Mikel Arteta’s 69th-minute free-kick levelled the scores and Villarreal wobbled. More than nerves, they were struggling to cope with Moyes’s substitute, Ferguson. After goalkeeper Mariano Barbosa’s flying save kept out one header, the Scot nodded in from the ensuing Arteta corner only for Collina to disallow the goal. “The momentum was definitely with us,” says Kilbane. “I feel if we had scored that goal we’d have gone on to win the tie.”

Collina has cited a vague challenge by Marcus Bent on Gonzalo Rodriguez when asked since about the decision but Kilbane adds: “I’d been refereed by him a few times in internationals and I always found him very good – you always felt he was making the right decisions for both sides but I felt that night he wasn’t the same Collina. He’ll always be remembered by Evertonians for that decision but throughout that night there was a lot going against us. He finished after that so he didn’t really have any consequences, did he?”

As it was, Diego Forlan’s last-minute breakaway goal sealed Everton’s fate. Pellegrini’s Yellow Submarine went on to sink United in the group stage, holding them to two 0-0 draws as they topped a section in which his new derby foes finished bottom. Their run only ended in the semi-finals with defeat by Arsenal and left them over £30m richer.

“For us to run Villarreal so close gave you a good idea of what a good side we had that year as well,” said Moyes.

Yet the disappointment of that defeat sent them spinning almost out of control. They lost 5-1 at Dinamo Bucharest in the Uefa Cup first round – one of seven defeats in eight games post-Villarreal. “It would have been a massive coup for the club and a massive step forward,” says Weir, “and then to get that kick in the teeth by not getting there was a massive low.” Moyes finally has Champions League football now but as he meets Pellegrini once more, the memory of a late summer night in a small Spanish stadium still lingers.