Marquez missed almost the entirety of 2020 due to a serious arm injury and has only one victory to his name this season.
It was so nearly two in a stunning tussle at the Aragon Grand Prix on Sunday, but it was Ducati rider Bagnaia who topped a premier-class podium for the first time in his career.
Speaking afterwards, Bagnaia – who now sits second in the riders' standings, 53 points adrift of Fabio Quartararo – struggled to comprehend the level of his achievement.
"I'm feeling a lot of emotion today, I'm so happy," he said.
"We worked a lot to achieve this result, every time we were close, something happened and the dream to win my first victory was far.
"I'm so happy, I have to say thanks to all the team, all my family, my fantastic girlfriend, who are all with me every day.
"It's difficult to say something now but it was not easy to stay in front of Marc at this track. His body is not at 100 per cent, I think today he was very, very competitive. I just tried to do my best, to finish first is a dream come true."
Marquez made several passes during the final few laps, only to cede back the position on each occasion in a race that thrilled to the finish.
The Repsol Honda rider thinks he proved a point with his battling display.
"Yeah, I mean like some people [said] the old Marquez is not there, today we showed it's the same mentality," he said.
"I still need to find the best level of myself. But anyway, it is a great result, I enjoyed a lot the race and the battle with Pecco on the last laps. I was a bit on the limit, but I think everybody was the same and I tried like always.
"Even coming in from two crashes in a row, I try, this is my style. Today Pecco was faster than us, he did an incredible race. It was not possible but anyway I'm really happy."
World champion Joan Mir came home third for Suzuki Ecstar and was disappointed not to have challenged the leaders.
"I feel tired, I gave 110 per cent," he said. "And honestly, I'm a bit disappointed today. I expected a little bit better today, the pace over the weekend was better than to make only a podium. I expected to fight with those guys.
"At the beginning, starting seventh position probably penalised us a little bit. I'm happy for the team, another podium is always a podium, but we want more, so let's push more."