Public Works Minister Anta Pastor, 58, got the speaker’s job under a deal between Rajoy’s conservative Popular Party (PP) and market-friendly upstarts Ciudadanos who came in fourth in the June 26 polls.
She was elected in the first post-election session of parliament, gaining 169 votes, ahead of Socialist lawmaker Patxi Lopez who got 155 votes.
Her appointment marks a small step forward for Rajoy, analysts said.
It suggests other parties may be more willing to have a greater willingness to work with him since the repeat polls.
Ciudadanos had backed Lopez for the speaker position after a December 20 general election but switched their support this time around to the PP’s candidate.
Rajoy has headed a caretaker government with limited powers since the December polls which resulted in a hung parliament.
Parties failed to agree on a coalition, prompting the repeat vote on June 26.
His PP won 137 seats — the most of any party and 14 more than in December but still not enough for an absolute majority in the 350-seat assembly.
To form a government the PP needs the backing of either its longtime Socialist opponents, who came second in the poll, or that of Ciudadanos and several smaller groups.
Pastor is seen as part of Rajoy’s inner circle.
She is a doctor from the northwestern region of Galicia where Rajoy also was born, served as health minister between 2002 and 2004 and has been public works minister since the PP was swept to power at the end of 2011.