Real Madrid got laughed out of another competition in the south. Serenaded home from Cádiz in the Cup, there were songs at Málaga in the league too. Time was ticking down at the Rosaleda and ticking down on the title, or so it seemed. The scoreboard showed 90 minutes and Málaga 1-1 Madrid, a result that saw the league slip a little further from their fingers, and up in the stands they were enjoying this. Fans in blue and white stripes smiled, waved and sang. “Goodbye to the league, goodbye!” the lyrics ran.

“The communion is important,” Málaga’s manager Javi Gracia says. “The objective is for our fans to feel participants in what we do: that’s the ultimate aim of any football team. Winning in any [old] way, without a sense of conviction and without winning over fans, without involving them, doesn’t bring complete happiness; you feel a little empty. Connecting with them is where true satisfaction comes from.” They connected here, all right. And not just because it was fun rubbing it in, but because Málaga had done it again; what they do better than anyone else in Spain.

No, this was not just about Madrid, even if everywhere you looked, it was all about Madrid: every headline, every report, every cover, every debate. “Let them sell the story they want,” insisted the Málaga defender Raúl Albentosa, who scored the equaliser. “The spectators here know what they have seen.” They had seen something familiar, something they’ve been watching for much of the season: a supremely well-organised team, clever, committed, giving everything, defying the odds yet again. One that deserved it when the final whistle went and the fans broke from singing at their opponents to give their own players a huge ovation. This was about them, not just about them.

Málaga are unbeaten against Madrid this season, just as last season they were the only team anywhere to play Barcelona and not be beaten by them, taking four points from six, and deservedly so: in 180 minutes, Barcelona managed just three shots on target and at the Camp Nou, Málaga didn’t just win, they had more chances. They also drew 2-2 with Atlético Madrid last year, denying them top spot and they are one of only three teams to have beaten them this season.

If they were a little lucky that day, it is no fluke: in the last three years no team has taken more points off the top three; a point or more in over than half of their games against Barcelona, Madrid and Atlético. “Results are a consequence of the way you play,” Gracia says. His team play different ways but they almost always play well. Better than anyone can seriously have expected.

It is less than three years since Málaga found themselves seconds away from the Champions League semi-final but it feels like a world away now: this team is not that team. When Abdullah bin-Nasser al-Thani bought Málaga he promised to compete with Madrid and Barcelona and he spent €160m building a team who could do that; his team finished fourth and headed into the Champions League where they almost reached the semi-final.

This was a real challenge, or so it seemed, but it did not last; now the challenge for Málaga is rather different, competing with the biggest clubs for days, not weeks. Al-Thani has not invested any money in the club for three years and that team has been dismantled piece by piece. Júlio Baptista, Joaquín, Nacho Monreal, Santi Cazorla, Ruud van Nistelrooy, Martín Demichelis, Jérémy Toulalan, and Isco have all gone. Only Duda and Ignacio Camacho are left from that team and even those who followed them have mostly gone. This weekend, Isco was back, applauded warmly, but he was playing for Madrid. Anyone who could raise money was sold. Soon, pretty much anyone who earned any money was sold too.

It started swiftly; the dream dying so fast they hardly had time to enjoy it. The first vice-president, Abdullah Ghubn, had gone and, faced with a European football ban, Moayad Shatat played the role of Málaga’s very own Mr Wolf, called upon to sort out a crisis. There was no more investment and some feared the worse; Cazorla was sold for a price the then-coach Manuel Pellegrini called a gift and others followed. Pellegrini left, Bernd Schuster left, and although Málaga stabilised there was no slowing down when it came to asset-stripping, even after Shatat’s departure.

Last season’s target was simple survival, with Gracia entrusted with developing younger players in a way that Pellegrini and Schuster had not. He did that and more. He believes in them: “There’s not such a tendency to look back as there would be with older players; younger players have it all to do still. Maybe more experienced players don’t have that,” he says. Málaga reached Christmas 2014 wondering if they might just get into Europe once more. Seventh then, they remained seventh all the way to week 35, eventually finishing ninth. It was, all things considered, a major success.

The problem was that pretty much everything Gracia did was then undone. “The magic word is cantera [the youth system],” El País insisted. “Samu, Darder, Samu Castillejo, Juanmi …” None of them are there any more. The two Samus went to Villarreal, Juanmi signed for Southampton and Sergi Darder went to Lyon. They were among eight players to depart, while seven news players arrived: at €500,000, Charles Dias de Oliveira was the only one who cost any money. Of their five highest scorers, four had gone and the fifth – Nordin Amrabat – would leave in the winter, for Watford. Four of the five players who played the most games had gone too. And it was not just who went, it was when they went: Darder departed at the end of the transfer window.

Gracia knows the reality. “My vision has to be young players that we can develop to build a better team. My objective is not to develop players to sell, it’s to develop players to have a better team. But if with time, teams come and pay for them, they’ll go. That’s not my objective, [but] there are others who tell you that economically it is necessary, so there you take a decision,” he admitted. This time, though, it was harder to accept: the timing, the impact, even the price … none of it really made sense.

“I can’t understand it,” Gracia insisted. He was furious and for once he said so: he had built his midfield around Darder, but now he had gone. There were two days left to sign but he insisted that he did not want anyone: “I’ll trust in the kids I have here,” he said. It is after all, what he does. And, rant over, his piece said, never to be raised again, that’s what he did, forced to start over again.

It was not the best way to start the season, though. And as if things weren’t going to be hard enough anyway, their campaign began with Sevilla, Barcelona, Villarreal and Real Madrid all inside the first six weeks. The day Gracia publicly lamented the loss of Darder, Málaga played at the Camp Nou. As usual, they competed better than anyone could have reasonably expected: they extended their run without conceding a goal against them to 254 minutes until, with nerves frayed and fans fretting, with Málaga midfielder Juankar almost scoring from inside his half, Thomas Vermaelen smacked in a 72nd-minute winner. Four weeks after that, they went to the Bernabéu and faced 31 shots, but relatively few really clear chances, and drew 0-0.

A solitary goal conceded in two games against Spain’s big two impressed but inevitably it was still a struggle. It took until Real Sociedad showed up in week seven for Málaga to even score, Charles hitting a hat-trick in a 3-1 win, and off the pitch there was uncertainty too. At the end of November, the director general Vicente Casado left. He was followed by Manuel Novo, the corporate director. Mario Husillos went too, the sporting director who brought Gracia to the club. There is a court battle between Casado and the club, and between Al-Thani and a hotel group over the shares. And at the end of week 12, Málaga were bottom.

Yet quietly, conscientiously, without raising his voice, Gracia carried on and results improved. So much so that of the last 12 games, Málaga have now lost just twice – 2-1 at the Pizjuán, where Sevilla have not lost in 12 matches, and 2-1 against Barcelona. From bottom, they’re now 11th. Europe looks possible once more. It is a miracle.

No one really talks about Gracia, including Gracia, but they should. Each morning, he arrives at his office at one end of the rubber warm-up track that doubles as a car park under the stand at the municipal athletics stadium where Málaga train. There’s a little cluster of desks there, papers and laptops, DVDs, statistics, whiteboards on the wall. He’s there by eight each morning and still there at eight at night, preparing matches still a month away. Then he goes home and watches football matches. He analyses everything; he can no longer help it. Just watching is impossible now.

“I’ve taught myself to see games and see things that are useful to me,” he says. “I see the back four, which way they move, where they try to get superiority, where the plays build from, I’m constantly looking at that. Everyone sees football their way and they’re all valid. My kids look at the colours of the boots; my wife looks at their haircuts. I notice other things …”

Important things. The depth of analysis is impressive, the questioning endless. Talk to him, listen to what he has to say, and it is impossible not to be impressed. He says he is “nobody to hand out lessons”, and there’s not a trace of arrogance about him, yet you can’t help but learn. “The ignorant man is the one who ‘knows’ everything,” he says. “Doubt is the essence of what I do.” Often he finds solutions, varied ones. Or ideas, at least. A way to stop the unstoppable, a means of overcoming a barrier. A cage for Lionel Messi, a trap for Luka Modric, a route past Diego Godín. Then he spends the week applying those ideas with his team. He is, players, admit pesado (hard work, heavy-going). But he carries the information lightly.

“I don’t feel like a protagonist; just a coach who prepares the games as best he can,” Gracia says. “He prepares games very well,” Miguel Torres insists. He seems to see weaknesses in the bigger sides that others do not. Against Barcelona last season, they denied space inside, sitting deep and waiting, but they did so with two different formations in the two games. Against Madrid at the start of this season they did something similar, but on Sunday the did the opposite, pushing high instead – suffocating them, not allowing them a way out. More like what they’d done against Barcelona four games before.

Málaga had been beaten that day, it is true. But then chance plays too. They’d pulled Barcelona apart in the first half only for Messi to score the winner in the second, the cover of Sport sighing: “Thanks, Leo”. “We went in at 1-1 and we didn’t deserve that,” admitted Andrés Iniesta, while Luis Enrique conceded: “They were the better team.” “If Luis says that, and they won the match, then I’m going to listen to that,” Gracia replied, rightly adding: “I leave here feeling like we deserved a bit more.”

It was no one off. On Sunday, his team got a 1-1 draw with Madrid that was celebrated in the stands and the sentiment was much the same: there was satisfaction not just at the score but at the way they had played; aware of how much of an achievement this was; the fans identified with them.

Against Madrid, Málaga’s starting XI cost a total of €1.85m plus the €1.5m Ignacio Camacho cost, signed in 2011, the sole survivor of a very different era. Meanwhile, even with Gareth Bale and Karim Benzema absent, Madrid’s cost €255m. And it was not just that Málaga drew with Madrid, it was that they might have beaten them – even if Cristiano Ronaldo did give Madrid the lead and then missed a penalty that would have made it 2-0.

When one Málaga centre-back pulled back a clever ball for the other Málaga centre-back to score the equaliser, Weligton supplying Albentosa and sending the goalkeeper Carlos Kameni cartwheeling round his area at the other end of the pitch, it was no more than they deserved. “We did what the coach wanted and we got the result; this is credit to all the players and I think we had the chances to have won the game,” Kameni said. Málaga had 11 shots, only three fewer than Madrid, and they’d had better ones. Juanpi, Ricardo Horta and Duje Cop all missed excellent chances and Charles saw a header saved by Keylor Navas – Madrid’s best player. In front of him, Navas’s team-mates couldn’t find a way out. Marca called it “torture”.

Carlos Kameni cartwheels in celebration of Raul Albentosa’s equaliser for Málaga against Real Madrid. Photograph: Gonzalo Arroyo Moreno/Getty Images

“Gracia’s side showed tactical order, suffocating pressure, and a perfect knowledge of its opponents, and only poor finishing denied them a win,” said the Málaga-based newspaper Diario Sur. Their headline cheered a “Gigantic Málaga”. “They dominated us in many things, but that doesn’t mean we played badly,” said Zinedine Zidane, but he knows that Madrid will be the focus and so does Gracia. Even if it shouldn’t be. “The effort was immense and the work exemplary. I would like people to recognise our players and what they have done. I’m proud of them: they deserve all the eulogies they get tomorrow,” he said.

Talking points

• “You think it’s lost, but it’s not for me, absolutely not: we will not give up,” Zidane told the press after the 1-1 draw at Málaga. He was right on the first thing, at least: “The league gets away,” ran the cover of AS; “Game over”, said El Mundo Deportivo, describing Barcelona’s lead as “almost definitive”. Madrid had left Barcelona the title “on a plate”, Marca insisted. Inside, Roberto Palomar described it as “another league title thrown in the bin”. Over in AS, mad Madridista Tomás Roncero was “depressed”: “no players, no pride, no self-esteem,” he complained.

“Goodbye to springtime with Zidane,” one headline ran, while El País said: “There’s no league with Zidane either.” All the good performances at home have not been enough: away they have played three times under him, all of them in Andalucía drawn two and won only one – a fortunate victory in Granada. The cover of Sport ran a picture of Ronaldo sitting on the turf, alone. “The End”, it said. Presumptuous perhaps, and it’s not actually over yet, of course, but the reaction was understandable.

Barcelona’s best weekend turned out to be the one when they played their worst football, scraping past Las Palmas 2-1. They gained two points on second, third, fourth, and fifth. Madrid’s draw left them nine points and a +4 head-to-head goal difference clear of their biggest rivals, while Atlético’s 0-0 draw with Villarreal four and half hours later, left them eight points and an unassailable head-to-head record clear of their nearest challengers. His eye on third place, Diego Simeone insisted: “We’re on course for our objective.” Real Madrid are not.

Logic suggests that one league title in seven years looks set to become one in eight, none in four years. Only once has anyone overhauled a gap this big, back in 1998-99, and there were 24 weeks left then; this time there are 13. Thirty-nine points available, 10 points to make up.

“The media say it’s over, that’s what they want, but we’ll fight on,” Marcelo insisted, but that may not be enough. Even if Madrid won every game, Barcelona would have to lose three times and lose the clásico by more than four goals, or drop points at least once more. Three defeats and a draw in 13 games, when they have lost twice and drawn three times in the previous 25. “Realistically, it’s even more difficult now,” Sergio Ramos said. “If we slip up once more we can forget it.”

• Marcelino was happy. Simeone was happy. Atlético 0-0 Villarreal suited them both. And, on one level at least, it really was a good result for both. No one else has stopped Atlético scoring at home this season. Only Málaga had stopped them scoring at all. Similarly, Villarreal are unbeaten in 12.

• José Luis Morales: superb. He scored a wonderful first, his sixth goal in the last seven games, as Levante defeated Getafe 3-0 on Friday night to climb off the bottom of the table. That’s five without a win for Getafe, who may just be dragged into trouble after all.

• Three in a row! Gary Neville is up and running. Valencia’s last two league games under him may just be their worse performances since he took over, but they won them both, plus that thumping victory against Rapid Vienna in the Europa League, and things look very different now. “The dressing room has changed significantly in terms of mood,” Neville said. He also said his first words in Spanish: “Four games in 10 days.”

• “They have given me their trust and I don’t think they’ll take it away now,” said Granada manager José Ramón Sandoval, perhaps a little optimistically?

• Susaeta scored. It was just a pity for Athletic that it was Néstor, not Markel. As they were playing the Basque derby against Real Sociedad, Markel’s cousin was giving Real Oviedo the lead in Girona (it finished 1-1). As for Markel, he could not score … and nor could any of his team-mates. The derby was settled with a belting goal from Jonathas which takes Real Sociedad on to four wins in a row and ninth in the table.

• Sevilla fans were not allowed into the ground because, it seems, they were carrying banners that carried the logo of the Biris ‘ultras’ supporters group on them. So they decided to cheer on their team from outside, at one point climbing up a ladder at the end of the stadium that’s not an end to fly the flag. The league’s criminalisation of fans continues, with its dangerous and unjust false equivalency.

Those that did get in enjoyed it. “This was a lovely game for the fans,” Unai Emery said after his side’s 2-2 draw with Rayo. It was also historic for Miku: no player has even scored five game in a row for Rayo before.

• Even more fun was Celta-Eibar.

Results: Levante 3-0 Getafe, Las Palmas 1-2 Barcelona, Espanyol 1-0 Deportivo, Betis 1-1 Sporting, Celta 3-2 Eibar, Rayo 2-2 Sevilla, Málaga 1-1 Madrid, Athletic 0-1 Real Sociedad, Granada 1-2 Valencia, Atlético 0-0 Villarreal.