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 26th polls.
Ana Pastor was elected as Speaker of Congress. Photo: Javier Soriano / AFP
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 20th general election but switched their support this time around to the PP's candidate.
"I want to govern...and I want to be allowed to govern," Rajoy told a news conference after Pastor was elected speaker.
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 26th.
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.
Ciudadanos leader Albert Rivera has already said his formation will abstain during a vote of confidence in parliament to allow the PP to form a government and he called on the Socialists to do the same.
"The PP and the Socialists can not continue their cold war," he told a news conference.
Mariano Rajoy observed MPs casting their votes for speaker. Photo: AFP
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.
However, Pastor's election to the role of speaker of congress was not free from controversy.
She was minister of public works when, in July 2014, a train sped off the rails outside Santiago de Compostela, killing 79 people and has faced accusations of not responding to the accident in a way that assumed political responsibility.
A member of the association of victims of the crash attempted to read out the names of the victims from the public gallery while she was being proclaimed Speaker but was swiftly removed from the chamber.
Spain's King Felipe VI will start a round of meetings with the representatives of the political parties before nominating a candidate to go to parliament and for a vote of confidence to form a government.
Rajoy is expected to attempt to win investiture in a vote on August 3rd if he can secure a promise that at the very least the PSOE will abstain and allow him to form a minority government.