After taking four points from their first two matches, a confident Rayo side made a fast start in front of their vociferous support, with Unai Lopez giving the home faithful a goal to celebrate in the ninth minute.
With his side unable to find a response before the break, Hansi Flick decided to make a change at the break, sending Olmo on to make his first La Liga appearance after Barcelona managed to register him in time for matchday three.
Olmo threatened to restore parity with a long-range shot, only to see his ambitious effort crash against the crossbar.
Barcelona's persistence ultimately paid off in the 69th minute when Pedri linked up with Raphinha to get the Blaugrana back on level terms.
The stage was set for Olmo to grab the headlines, with the Spain international receiving the ball in the box before guiding a left-foot shot into the far corner.
The Blaugrana held on to their slender advantage to record a third consecutive 2-1 victory, ensuring they are the only team yet to drop points in La Liga this season.
Barcelona are guaranteed to head into the weekend in top spot, while Rayo are currently sitting in eighth position.
RAYO VALLECANO VS. BARCELONA HIGHLIGHTS
Lopez goal vs. Barcelona (9th min, Rayo Vallecano 1-0 Barcelona)
Rayo take an early lead at Vallecas. The 28-year-old sweeps the ball in at the near post after meeting Jorge de Frutos's neat cutback. It is Lopez's first La Liga goal since netting the opener against Barcelona in a 1-1 home draw in November 2023.
Pedri goal vs. Rayo Vallecano (60th min, Rayo Vallecano 1-1 Barcelona)
Barcelona's positive start to the second half results in a deserved equaliser. The midfielder continues his run after playing the ball out to Raphinha on the left flank. He receives the ball back from the Brazilian before sending a precise left-foot shot into the bottom corner.
Lewandowski's disallowed goal vs. Rayo Vallecano (71st min)
Lewandowski finds the net. The Poland international collects a parry and takes his time before picking the opportunity moment to pass the ball into the far corner. However, the referee heads to the VAR monitor before chalking the goal off for a foul against Jules Kounde.
Olmo goal vs. Rayo Vallecano (82nd min, Rayo Vallecano 1-2 Barcelona))
There is nothing wrong with this goal. After collecting the ball from Yamal, Olmo drives a left-foot strike past the despairing Dani Cardenas to net his first La Liga goal.
MAN OF THE MATCH - DANI OLMO
Olmo may have only been introduced at half time, but he demonstrated why Barcelona made the effort to sign him from RB Leipzig this summer.
The Euro 2024 winner was unfortunate not to grab a goal before the hour mark when he saw his long-range shot rattled the Rayo crossbar.
He continued to offer a real threat throughout the duration of his performance and ultimately deserved the privilege of scoring the winning goal
RAYO VALLECANO VS. BARCELONA MATCH STATS
Possession: Rayo Vallecano 35%-65% Barcelona
Shots: Rayo Vallecano 7-22 Barcelona
Shots on target: Rayo Vallecano 4-5 Barcelona
Corners: Rayo Vallecano 6-6 Barcelona
Fouls: Rayo Vallecano 17-11 Barcelona
BEST STATS
WHAT NEXT?
After recording a third consecutive win, Barcelona will attempt to maintain their 100% record when play host to newly-promoted Real Valladolid on Saturday.
As for Rayo, they will look to bounce back from their first defeat of the season in Saturday's away clash with Espanyol.