Oscar got the winner in the 111th minute, lobbing a shot from the right that was tipped by Portugal keeper Mika onto the underside of the crossbar before going in. He also scored in the 5th minute, and again in the 78th.
Alex leveled in the 9th minute for Portugal and Nelson Oliveira's 59th minute goal put the Europeans ahead. Brazil fought back to take its fifth U-20 title, having been the runner-up two years ago. Portugal was seeking its third title.
Brazil was the clear favorite for the match between former colony and colonizer, but it was an even contest from start to finish, with only the brilliance of Oscar making the difference.
''This really makes us happy, because now we have matched the record of the senior team,'' Brazil coach Ney Franco said, referring to the five World Cups Brazil's top side has won.
Portugal coach Ilidio Vale said the result was ''not completely just'' but acknowledged Brazil's ''high quality team.''
''We were close to the dream, but we could not quite win it,'' Ilidio said.
Asked about Ilidio's claim of injustice, Franco replied: ''I disagree with what he (Ilidio) said. ''The trophy is in our lockerroom.''
Oscar made the difference with his three goals - his first three of the 3 1/2-week tournament - in a performance that is sure to bring the big European clubs knocking on the door of the 19-year-old Internacional playmaker.
He broke through in spectacular style, sending a 40-meter (yard) free kick into the far corner, catching goalkeeper Mika flat-footed. It was the first goal yielded by Portugal in the tournament after six clean sheets in the previous matches.
Oliveira set up Portugal's equalizer when he ran to the byline and cut the ball back across the face of the goal with Alex tapping it home.
Just a minute later, Brazil appeared to score, with a bouncing ball going over the Mika's head. Replays suggested the ball had crossed the line, but American referee Mark Geiger let play go on.
Brazil always looked more threatening in the first half but could not find a way through Portugal's formidable defense, crowding the front of the goal. The South Americans led in every statistical category in the first half and had 55 percent of the possession.
Oliveira put Portugal ahead in the 59th. He broke down the right, beat defender Juan and his shot from a sharp angle beat Brazil goalkeeper Gabriel at the near post.
Brazil's equalizer came in the 78th. Mika blocked the initial shot by Dudu, but Oscar slotted the ball home.
Brazil had a slight edge in possession over the 90 minutes and a 9-4 edge in shots on target, though Portugal often looked the more threatening.
Prior to Oscar's winner, the best chance in extra time fell to Portugal's Cateano, who broke down the right and forced Gabriel into a point-blank save, knocking the ball away with both hands.
Both teams seemed run down in the final minutes, perhaps affected by playing at 8,600 feet in the Colombia capital. However Ilidio said ''I don't think the altitude was an important factor. We had chances to score in win in extra time, as did Brazil.''
The result avenged the result of the 1991 final, when Portugal defeated Brazil on penalties.
Portugal has won the U-20 title twice, far behind the leader Argentina with six.
Ulises Davila, Jorge Enriquez and Edson Rivera scored unanswered goals after Alexandre Lacazette had put France ahead with an 8th-minute header.
The third-place finish comes after Mexico's senior team defeated the United States in the final of the regional Gold Cup tournament in June, and Mexico won the Under-17 World Cup title in July.