Vinicius appeared to put Brazil ahead in the 64th minute as he skipped past Elvedi and coolly slotted a shot into the bottom corner. But the goal was disallowed after VAR ruled that Richarlison was offside in the buildup.
Portugal got a penalty in the last minute after the VAR spotted Jose Maria Gimenez's handball in the area, and Fernandes produced a calm finish, before seeing another effort bounce back off the woodwork in injury time.