Nikola Vlasic and Ivan Perisic were also on target for Croatia in a victory that lifted Zlatko Dalic's side, so leggy and unconvincing in their first two games, up to second in Group D on four points.
They finished ahead, on goals scored, of the Czech Republic, who lost 1-0 to group winners England. Croatia next face the runner-up of Group E - where Sweden, Slovakia, Spain and Poland are all still jockeying for position - in Copenhagen on June 28.
Scotland, who scored their only goal of the tournament through Callum McGregor, finished bottom of the pile on one point, falling to earth with a thump after their positive performance against England at Wembley lifted hopes of reaching the knockouts of a major tournament for the first time.
Modric's form had been called into question at the tournament, but the 35-year-old shaped a delightful finish into the corner of the net with the outside of his foot in the second half to make it 2-1, sending his side on to a thoroughly deserved victory.
Deprived of Billy Gilmour, who failed a COVID-19 test in the buildup, Scotland seemed lacking in midfield and Croatia bossed the ball, dominating possession for large periods before deservedly taking the lead after 17 minutes as Vlasic scored his sixth goal for his country.
There seemed little danger when a cross from the right floated towards the far post but Perisic towered above his marker to head down for Vlasic to swivel and finish low into bottom corner.
The goal drained the life out of Hampden Park and Scotland's fortunes did not look like improving as Croatia stroked passes around the pitch, but just as the World Cup finalists seemed likely to turn the screw further, Steve Clarke's side struck back.
As the clocked ticked towards halftime, Croatia failed to clear a cross from the left and it fell at the feet of McGregor just outside the box.
He took a touch and drilled the ball low into the bottom corner to score his first goal for his country, and Scotland's first in any major tournament for 23 years, breathing life back into the home crowd.
Having dragged themselves back into the match Scotland almost fell behind again at the start of the second half but Josko Gvardiol let his first touch get away from him when one-on-one with Scotland keeper David Marshall and a superb chance went begging.
The reprieve did not last long.
Scotland's John McGinn wasted a great chance when he failed to get a proper connection on the ball from less than a metre out at the far post and that was punished at the other end by Modric's moment of inspiration.
Croatia worked the ball nicely around the box before teeing up Modric from 20 metres and he shaped the ball delicately with the outside of his foot into the far corner to restore Croatia's lead after 62 minutes.
Perisic applied the coup de grace in the 77th minute, sending a glancing header from a corner into the net, ensuring that Scotland's dreadful run of never making the knockouts at a major tournament in 11 attempts continued.
England get the job done
Soccer Football - Euro 2020 - Group D - Czech Republic v England - Wembley Stadium, London, Britain - June 22, 2021 England's Jordan Henderson scores a goal which is later disallowed. (Photo: Reuters)
England delivered an efficient but hardly scintillating display to beat Czech Republic 1-0 with an early Raheem Sterling header on the same day to advance to Euro 2020's last 16 as Group D winners, with the Czechs through as one of the best third-placed teams.
Sterling scored his and England's second goal of the competition in the 12th minute but the initial injection of pace, intensity and crowd-pleasing excitement brought by Jack Grealish and teenager Bukayo Saka gradually dissipated as the game petered out into an utterly forgettable second half.
Neither coach will mind though as they now begin to plot their assaults on the knockout phase.
England will return to Wembley on Tuesday to face the runners up from Group E - likely to be France, Germany or Portugal - while the Czechs will have to wait to find out who they play. They were dislodged from second place by Croatia, who beat Scotland 3-1 and will play the Group E runners up - Sweden, Slovakia, Spain or Poland - in Copenhagen on Monday.
The match began in a strange Wembley atmosphere, a far cry from the initial excitement of the Croatia and Scotland games.
With both teams already assured of progress and with the nagging question of whether second place was a better option than winning the group hanging over the game, it hardly added up to a white knuckle, winner takes all occasion.
That changed quickly, however as, for the third successive game, England struck a post early on, this time it was Sterling who lifted the ball past advancing goalkeeper Tomas Vaclik with two minutes on the clock.
Ten minutes later Sterling hit the target with a close-range header from a delicious floated cross by Grealish after a driving run by Saka had splintered the Czech rearguard.
Making his first appearance of the tournament, the 19-year-old wide man showed a willingness to run with the ball that was painfully absent from England’s first two performances and, with Grealish also a constant threat, the hosts looked much more threatening.
Harry Kane looked sharper too and had a shot well saved late in the first half by Vaclik, but that early promise was gradually replaced by the all-too-familiar caution and England barely mustered another meaningful attempt.
The Czechs were neat and tidy without carrying a huge amount of penalty box threat, though Tomas Holes had a shot palmed clear by Jordan Pickford and Tomas Soucek fired just wide in the first half.
Substitute Jordan Henderson thought he had scored his first goal for England five minutes from time after a scramble, only to see it ruled out for offside.
Overall though it was desperately thin gruel for most of the second half, with the loudest cheers reserved for the big screen announcements of Croatia's goals that eliminated Scotland.