* In-form Ronaldo scores twice in 3-2 away victory
* Brave Rayo fight back with two second-half penalties
* Third-placed Real trim gap to Atletico to two points (Adds Sevilla-Celta result)
By Iain Rogers
MADRID, Nov 2 (Reuters) - Unconvincing Real Madrid survived a huge scare at rock bottom Rayo Vallecano when they conceded two quickfire second-half penalties but held on under severe pressure to secure a nervy 3-2 victory in La Liga on Saturday.
The world's richest club by income, who play at Italian champions Juventus in Europe on Tuesday, were flying when a Cristiano Ronaldo double and a goal from Karim Benzema put them 3-0 ahead shortly after halftime.
However, Carlo Ancelotti's expensively-assembled side were unable to control the match against their lowly city rivals and were left reeling when Jonathan Viera struck twice from the spot in three minutes after clumsy fouls by Pepe and Marcelo.
A valiant Rayo, whose squad is worth less than a tenth of their illustrious neighbours' and whose fans unfurled a gigantic banner reading "Proud to be Poor" before kickoff, came close to equalising several times.
Real goalkeeper Diego Lopez saved his team with a host of fine saves and tipped an Alberto Bueno shot on to the post in the 65th minute.
Real's glaring defensive failings will concern Ancelotti before the Juve game but the win trimmed the gap to second-placed Atletico Madrid to two points ahead of the latter's game at home to Athletic Bilbao on Sunday.
Unbeaten champions Barcelona are top with 34 points from 12 matches after their 1-0 win at home to Espanyol in Friday's Catalan derby, with Atletico on 30 and Real on 28.
"The second half was a disaster," Ancelotti said at his post-match news conference.
"We have to change and iron out the superficiality that we showed on the pitch," added the Italian, who has struggled to get the best from his players since taking over from Jose Mourinho in the close season.
"We can't let teams back into a game like that when you have the quality of Real Madrid."
Rayo coach Paco Jemez, whose team play some attractive football but have by far the worst defensive record in Spain's top flight, said he was "very proud" of his players.
"I am coming away with the knowledge that at least we gave our all and we never threw in the towel," he told reporters.
"We have to take strength from this. We had Madrid against the wall and we can do that to anyone."
It was a stirring Rayo performance before their vociferous fans and overshadowed another fine display from Real's world record signing Gareth Bale, whose start at the club after joining from Tottenham Hotspur has been disrupted by injury.
The 100 million-euro ($135 million) Wales winger followed up Wednesday's two goals and two assists in the 7-3 home win over Sevilla when he set up Ronaldo and Benzema with fine crosses at Rayo's unfashionable Vallecas stadium in the Madrid suburbs.
Ronaldo's two goals lifted the prolific Portuguese forward to the top of the La Liga scoring chart on 13 goals, one ahead of Atletico's Brazil-born striker Diego Costa.
"They were very intense in the second half and they really made us suffer," Lopez said in an interview with Spanish television broadcaster Canal Plus.
"The two penalties let them back into the match and we knew this would be a tough place to get the points."
Real Sociedad showed off their attacking prowess ahead of Tuesday's Champions League match against visitors Manchester United when the Basque club won 5-0 at home to 10-man Osasuna to climb to seventh.
Defenders Ion Ansotegi and Inigo Martinez struck with headers either side of halftime at the Anoeta before Osasuna centre back Jordan Loties was shown a straight red card for tripping Carlos Vela when he was through on goal.
Forward Antoine Griezmann nodded a third in the 56th minute, Gonzalo Castro finished off a sweeping break in the 82nd and substitute Haris Seferovic helped himself to a goal two minutes from time as the visitors crumbled.
San Sebastian-based Sociedad have 17 points, two behind sixth-placed Getafe who host Valencia on Sunday (1100 GMT), while Pamplona club Osasuna are mired in 16th spot, a point above the relegation places.
Sevilla's erratic form continued when they lost 1-0 at home to Celta Vigo after a howler by goalkeeper Beto allowed Alex Lopez to score and they remain 11th on 13 points.
Promoted Almeria's 1-0 victory against visiting Real Valladolid, the south coast club's second win of the campaign, lifted them above Rayo on goal difference with nine points.
($1 = 0.7414 euros) (Editing by Ed Osmond and Ken Ferris)