RIO DE JANEIRO (AP) — After struggling for much of his Olympic singles quarterfinal against a Brazilian opponent backed by a raucous home crowd, Rafael Nadal finally seized control by using a big backhand to set up an easy putaway at the net for a third-set service break.

Perhaps wary of drawing the ire of all of those flag-waving fans, Nadal offered a rather muted reaction — none of the leaps or uppercuts or yells of "Vamos!" he'd displayed earlier at the Rio de Janeiro Games.

Nadal moved into the semifinals as he bids to add a second singles gold to the one he earned for Spain in 2008, handling a hostile environment and coming back to beat 54th-ranked Thomaz Bellucci 2-6, 6-4, 6-2 on Friday. And then he went back out on court and teamed with Marc Lopez to win the men's doubles title, edging Florin Mergea and Horia Tecau of Romania 6-2, 3-6, 6-4 in that final.

"I don't even know how things are going so well," said Nadal, who missed the past 2½ months with an injured left wrist, "because I didn't do any preparation for the tournament."

Andy Murray, the defending champion from Britain, also is trying to become the first tennis player with a pair of Olympic singles titles. He found himself in an even tenser, tighter match, before emerging to edge Steve Johnson of the United States 6-0, 4-6, 7-6 (2).

"Close to going out," Murray said after winning despite trailing by a break in the third set for the second match in a row. "Sometimes that can work in your favor as the tournament goes on. You start to feel a little bit better. You loosen up a little bit."

On Saturday, Nadal will play 2009 U.S. Open champion Juan Martin del Potro of Argentina, while Murray faces Kei Nishikori of Japan.

Del Potro, who knocked out No. 1 Novak Djokovic in the first round, beat Roberto Bautista Agut of Spain 7-5, 7-6 (4). Nishikori got past Gael Monfils of France 7-6 (4), 4-6, 7-6 (6).

The women's final is also Saturday, when Monica Puig attempts to win Puerto Rico's first gold medal in any sport in Olympic history. She beat two-time Wimbledon champion Petra Kvitova of the Czech Republic 6-4, 1-6, 6-3, and will face Angelique Kerber of Germany, the Australian Open champion who defeated Madison Keys of the U.S. 6-3, 7-5. Kvitova meets Keys for the bronze.

"This Olympics isn't about me," the 34th-ranked Puig said. "It's about Puerto Rico, and I know how bad they want this."

No matter what happens in his singles semifinal, Nadal will get to leave Rio with a medal from doubles. Not bad for a guy who missed the London Games four years ago because of a knee injury, then came to Brazil with a wrist he says is not fully healed.

"Maybe he's not (enjoying) the best time of his career," Bellucci said, "but he's playing really well."

Nadal is a former No. 1 and owns 14 Grand Slam titles. Bellucci, who lives in Sao Paulo, is also a lefty, but that's pretty much where the similarities end.

He reached a career-best ranking of 21st in 2010, not long after making his only trip to the fourth round of a major tournament. He arrived at his home Olympics with an 11-18 record in 2016 — and a career losing mark, too.

It was Nadal who started shakily, though, committing 10 unforced errors and generating only two winners in the opening set. He was broken twice and never earned so much as a single break chance.

Nadal cleaned things up in the second, though, and while he did get broken again while serving for it at 5-3, he broke right back with a running cross-court forehand passing winner to force a third.

Following a shanked forehand early in the final set, Nadal kicked his foot against the court. At the time, it appeared to be a sign of frustration. But at the ensuing changeover, Nadal removed his left shoe so a trainer could tape up the little toe on that foot.

Right after that lengthy break, Nadal broke at love to go ahead 3-1, and that was pretty much that.

Still, Bellucci enjoyed the atmosphere. Fans cheered for Nadal's miscues — even faults, generally considered a no-no in tennis — and roared for Bellucci's best shots as if victory and defeat hung in the balance with each point.

When their guy would grab a game, they would sing, soccer-style, "Ole, ole, ole, ole! Tho-maz! Tho-maz!"

They reprised that chorus even after he lost.

"It was, Bellucci said, "amazing for me."