This is Age of the Great Dinosaurs (1979).
From TV Tropes:
Daikyouryu no Jidai (Age of the Great Dinosaurs in Japanese) is a rather obscure fantasy/adventure anime film distributed by Ishimori Productions and Toei Animation. Directed by Shotaro Ishinomori and Hideki Takayama, it was released in 1979, and narrates the story of a trio of kids (Jun, Remi and her little brother Chobi) from modernized Japan who still treat nature with respect and conscience, unlike many other humans who pollute Earth and damage the planet a lot every day.
One fateful night they are summoned by an unknown alien intelligence who tells them that mankind is losing its empathy, and, to teach them a lesson about life, death, and the fall of species, said alien intelligence transports the kids to Earth's past and leaves them right in the Mesozoic era, the time when dinosaurs were the supreme rulers of the Earth. Here, the trio has a series of adventures and misadventures, like befriending a baby Triceratops, trying to escape from a dangerous Tyrannosaurus rex, witnessing the Cretaceous extinction and rise of the mammals, and discovering why it is important for humans to protect Earth before it's too late.
As mentioned above, the film is very poorly-known, and only a few home releases are known. It can be watched for free online, but is usually found in a foreign language, like Spanish.
Alas, Poor Villain: The Tyrannosaurus eventually gets speared to death by the Neanderthals, though this becomes sorrowful considering it's the Last of Its Kind.
The main male protagonist has dark hair and wears a dark blue top, similar to your description. And you can view the T-Rex being killed by numerous hurled spears right around the 1:01:35 mark in the video below.