(CNN) Daniil Medvedev appears to be relishing the role of US Open villain.

For the third match in a row, the No. 5 seed needed four sets to advance. And for the second time in two days, the Russian agitated the crowd at Louis Armstrong Stadium.

On Sunday, Medvedev defeated German qualifier and 118th-ranked Dominik Koepfer 3-6, 6-3, 6-2, 7-6(2) in two hours, 32 minutes to reach his first major quarterfinal.

While it was clear that Koepfer had his supporters, the atmosphere was calm. That changed when Medvedev won match point. It was then the 23-year-old Russian started strutting, which riled up the crowd.

Dancing his way into the final eight! 🕺 Daniil Medvedev is through to the first Grand Slam quarterfinal of his career after fighting past Koepfer in four sets. @DaniilMedwed | #USOpen pic.twitter.com/wbTz7jahMr

He went on to point his arms skyward, gesturing for more from the fans.

Medvedev, who was seen wearing kinesio tape on his arm, shoulder and legs during the match, said to the crowd, "I was painful in my abductor before the match. I thought I'm not going to play. I was painful in my shoulder. I took as much painkillers as I could. And you guys, being against me, you gave me so much energy to win. Thank you."

The crowd continued to jeer.

"Guys, continue to give me this energy," Medvedev said. "You're the best."

Medvedev next will face No. 23 seed Stan Wawrinka -- who shocked world No. 1 and defending champion Novak Djokovic -- in the quarterfinals.

"After the match, I engaged a little bit with the crowd," Medvedev said to reporters. "But we all know how New York crowd can be. It's probably the most electric crowd in the world, I think. Especially, I mean, playing this week on big courts, I could feel it. Today I was just engaging with the crowd and hopefully -- hopefully it was fun for them and for me. As I said, it gave me a lot of energy to win."

As for the dance?

"I was just so happy about my win today that I just decided to do something special my first quarterfinal," he said. "Because I saw some comments already that some people think it was against the crowd. It was not at all. It was just showing how happy I was to be in the quarters."

JUST WATCHED Remembering the Original 9, the pioneers of women's tennis Replay More Videos ... MUST WATCH

On Friday, Medvedev defeated Spaniard Feliciano Lopez 7-6(1), 4-6, 7-6(7), 6-4 -- his second four-set win in consecutive days -- but it was his unruly behavior on the court that had fans lustily booing the 23-year-old at Louis Armstrong Stadium.

Medvedev first got under the fans' skin in the first set, when he received a code violation after he angrily grabbed a towel from a ballperson. When learning of the violation that chair umpire Damien Dumusois had given him, Medvedev threw his racket.

Later, after a confrontation with Dumusois, TV cameras picked up Medvedev putting a hand to his head giving the middle finger -- outside of the view of Dumusois. Boos rained down from the crowd, and Lopez quickly became the fan favorite.

After he won, surrounded by boos, Medvedev raised up his arms, motioning to the crowd to keep going.

"Thank you all, guys, because your energy tonight gave me the win," Medvedev said in an interview on court. "Because if you were not here, guys, I probably would lose the match. Because I was so tired, I was cramping yesterday. It was so tough on me. So I want all of you to know when you sleep tonight, I won because of you."

The boos continued.

"The energy you're giving me right now, guys, I think it will be enough for my five next matches. I mean, the more you do this, the more I will win for you guys."

Heading into Sunday, Medvedev has racked up $19,000 in fines at the US Open: $7,500 for verbal abuse in the first round, $2,500 for abuse of his racket in the second round and $5,000 for unsportsmanlike conduct and $4,000 for a visible obscenity in the third round.

In his post-match press conference on Sunday, Medvedev said he's working on his behavior.

"I was an idiot to be honest," Medvedev said of his on-court actions on Friday. "I did some things I'm not proud of."

Medvedev has dominated on the hard courts this summer, including winning his first Masters 1000 title at the Western & Southern Open in the Cincinnati suburb of Mason, Ohio, in August. He leads the ATP Tour this season with overall match wins (48), wins on hard courts (35) and finals appearances (six).