In the middle of Rayo Vallecano's dark days, when they'd been beaten 15 times in 20 games and the goals were flying in; when they'd let in five from Atlético Madrid, five from Málaga, five from Villarreal, four from Espanyol, four from Sevilla, four from Barcelona, three from Madrid, three from Osasuna, and three from Valladolid; when they plummeted to 19th and stayed there for 11 long weeks; when the only reason they didn't fall further was that Betis were even worse; when even a glimmer of hope, a 4-1 win over Málaga, immediately gave way to a six-goal hammering; and when relegation wasn't an "if" but a "when"; there was a phrase that got repeated over and over: Paco Jémez will die with his ideas.

Paco Jémez, though, had other ideas. Not because Rayo's coach was going to back down on his principles – "any club that signs me knows what it's getting," he insisted – but because he didn't have any intention of dying at all.

Even when Rayo were a disaster, Jémez had his defenders. Off the pitch, that is. Last season, only two teams in Europe had the ball more than Rayo did: Barcelona and Bayern Munich. Early this season, when Rayo played Barcelona, they had more possession than them, the first team to manage it in 316 games. They threw men into attack, they were fun to watch, and parading the touchline in a dizzying array of multicoloured elbow patches and waistcoats, pink shirts and purple ties, Jémez urged them forward, always. In a country that values the aesthetic, or in which some do, he was eulogised for the way his teams played de tú a tú: as equals. Rayo didn't simply defend – sometimes they didn't defend at all – but instead they went for it.

And, mostly, they lost. Rayo took the ball off Barcelona and Jémez declared himself "very proud". But they were beaten 4-0. They went to the Camp Nou where they were praised by Barcelona's players but they were beaten 6-0. This wasn't brave, said his critics, this was stupid; "there is a fine line between braveness and temerity," Jémez admitted. Familiar trenches were dug and this became another moral battle, almost an ideological war. The stupider they said it was over there; the purer they said it was over here, as if there was something deeper and less tangible. "At times of crisis, people spend money to see us play: we've got a responsibility to play nice football, otherwise what the hell are they spending their money for?" Jémez said and while some applauded, others groaned.

They all agreed on one thing: Paco Jémez was going to die with his ideas. Yet the focus on deeper meaning hid the ultimate meaning: to compete. Talk of style hid the substance. Jémez's WhatsApp status ran: "The only satisfaction to be derived from losing is knowing that you did all you could to win." That's the only satisfaction, not the satisfaction. Somehow the debate had become perverted, as if Jémez was trying to lose.

He wasn't. He insisted his team did not cross that line between bravery and temerity. The defeats came, he said, not because of the approach, not because they were too far forward but because of lapses of concentration; the application, not the idea, was at fault. He talked about a team who kept "slitting its wrists".

The defeats also came because they had to come; relegation beckoned because it has to beckon. Rayo are the poorest team in the division; their annual budget is €7m. Real Madrid's is over €500m. Rayo's squad cost a total of €0.

In 2011-12, their first season in the top flight for eight years, Rayo survived in the last minute of the last day. Last season Rayo started with five defeats in nine games, conceding six against Valladolid, five against Barcelona, four against Atlético and three against Espanyol; they finished the season in a European place that they could not take up because of their financial crisis. It was their best finish. In the summer, 12 players arrived and 11 departed; half the squad were new. The men who left included their two central defenders and their three top scorers. They have not repeated a starting XI and not always because Jémez hasn't wanted to.

As he himself put it: "We're the shittiest team in the league and unless we realise that we will suffer." But realising that did not mean rolling into a ball and protecting themselves; in the long run that may be no protection at all.

Sitting back was no guarantee, quite the opposite. "If, as well as being small, you're a coward, you're going to get a beating from all sides," the coach told Panenka magazine. So Rayo went for teams. Only Madrid and Barcelona have attempted or completed more passes than them, only four clubs have put the ball in the opposition area more and only six teams have created more chances. Rayo have scored more than half of the league. Their goalkeeper has only made one save more than Real Madrid's. Levante's Keylor Navas has made almost twice as many.

The nerves grew, the gap too, and relegation beckoned but the way Jémez saw it, eventually the wins had to come. "The people who say we're dead turn me on," he said. That didn't include the fans who, even as they feared, even if they appealed for a little pragmatism too, continued to support the team. "Giving their all" tends to mean running around a lot, defending "heroically"; in Vallecas it meant something different. When they were defeated against Sevilla at the end of February, supporters chanted and shouted until the team came back out and then gave them a standing ovation. Rayo had taken 10 shots but lost 1-0.

Then, in March, the results did come. Against Valencia, Rayo went into the game five points from safety and Valencia were unbeaten in a month. They won 1-0. Then they went to San Sebastián and won 3-2. And this weekend, they faced Almería. It was 18th against 19th and the normal cliché underwent inflation. This was a relegation seven pointer: the three points you could win, the three points you could stop them winning, and the chance to secure a head-to-head advantage, decisive if the sides finish level. Vallecas was packed on three sides, the Marseilles rang out: "to arms!", drums beat and bodies bounced and Rayo blew Almería apart.

Alberto Bueno scored an "'ave it" of a header to open the scoring. Roberto Trashorras took control and Almería couldn't handle Rubén Rochina or Iago Falqué on the wings. Virtually the whole game was played in Almería's half. Pressured and pushed back, they could not find a way out; the visitors had only two shots on target, although Fernando Soriano scored from one of them to momentarily give them hope. Almería's keeper Esteban prevented more but Rayo's second to make it 2-0 and third, which made it 3-1, were genuinely wonderful goals, precision constructed on the left, Almería sliced open until all that was left was to pass the ball into the net.

For the first time in 12 weeks, Rayo are out of the relegation zone. "This is a giant step," a smiling Rochina said. They have won three in a row, four in the last six. "Now we can try to do something that only the very biggest teams do: win four in a row," Jémez said. This was his 25th first division victory as manager of Rayo, overtaking Juande Ramos for a new club record. From 17 points in 22 games to 12 in six and nine in three, this morning they stand three points clear. "Sí, se puede!" the fans chanted: Yes, we can! When the third goal went in, another chant went up, tongue in cheek, European ambitions. "Next year, Rayo-Liverpool!"

"The fans gave us everything and expected nothing in return and when someone does that they've won you for ever. One of the key reasons we have recovered is them. If we play football it is for them, so that they can enjoy football. If not, this game has no meaning," Jémez said. But, he added: "I have to be a party-pooper: we've still only got 29 points." Survival is likely to require 40 points. At least now it is possible, maybe even probable.

Errors have been ironed out of their game, the focus is firmer. It would be nonsense to say that they haven't changed, that they haven't made improvements, that lessons have gone unheeded, but there has been continuity too. "We're a tougher side now," Bueno insisted. "We're not committing the same mistakes that cost us so many points."

When Rayo got the third, Jémez pulled his centre-back Alejandro Gálvez over to the touchline and talked him through the Almería goal six minutes earlier. From an average of 2.4 goals conceded per game, they're on one-a-game over the last four matches. Not including the Barcelona battering, their one defeat in seven, they have conceded five in the last six games. There was even a 0-0 draw with Levante.

"Of course you're always improving things, making adjustments, but the fundamental idea is the same. If it hadn't been, we would not be as strong now: you can't go changing every day. We never thought of taking a different path. I wouldn't do it any other way," Jémez said. "But I have never wanted to die with my ideas; I have always wanted to win with my ideas, to live with them. I don't do this to die."

Talking points

• Barcelona are back? It's too easy to say, not least because they have mostly played well at home this season and the real tests come away. Meanwhile a crisis always lurks just around the corner, but they were impressive in winning 7-0 against Osasuna. Some of the pressure and speed was there again and they looked more themselves with Pedro rather than Neymar. The focus though was on Leo Messi who scored a hat-trick, making him the club's all-time top scorer, overtaking Paulino Alcántara.

• Real Madrid and Atlético, Cristiano Ronaldo and Diego Costa, both got 1-0 wins to keep the top of the table looking the same for another week. Next Sunday: the clásico. If only someone had written, etc and so on ...

• Typical. All year, you sit through frankly pretty dire games at Getafe and then one day your flight gets in late and you don't go ... and they and Granada only go and score six goals between them. Apparently, the atmosphere was pretty good too. Getafe were under new management, after Cosmin Contra took over from Luis García. But, although there was improvement, he could not end the run without a win: it's 13 weeks now for Getafe, they're two points off the relegation zone and their run-in may be the hardest of the teams down there.

• Goal of the week? Well, Kevin Gameiro's first for Sevilla was pretty tasty ... they beat Valladolid 4-1 ... but it is all about the game against Betis in the Europa League on Thursday. Sevilla are 2-0 down from the (home) first leg. But, said the scoreboard, alongside a picture of them celebrating Uefa Cup success, "Europe knows what we're capable of."

• "Some people are being ridiculous when it comes to referees." This column is liking Ernesto Valverde more and more.