The Seleccao blew a two-goal lead against Morten Olsen's side but Silvestre Varela popped up with a late winner to keep them in contention for a place in the quarter-final
The Seleccao were 2-0 up after just 36 minutes thanks to goals from Pepe and Helder Postiga, but they were pegged back by Nicklas Bendtner, who notched just before the break and then again with just 10 minutes remaining.
However, Silvestre Varela netted a late winner for Portugal to keep their hopes of qualifying for the knockout stages alive.
"We deserved the victory, but we suffered too much, considering what we did [in the first half]," Bento told SIC after the game in Lviv.
"We defended well in the first half, showing some good organisation, and there was a period in which we could have scored twice [more] but Denmark ended up scoring with the only chance they had.
"In the second half, our plan was to make it 3-1 and not see it out at 2-1. A minute before Denmark's equalised, we could have killed off the game [through Cristiano Ronaldo].
"Then our players' character and personality emerged. They have been working in an extraordinary way."
Portugal, who were beaten by Germany in their tournament opener, will now travel to Kharkiv to take on the Netherlands in the decisive last round of group matches.