Ecuador were the better side for much of the first half, with John Yeboah and Alan Minda both striking the crossbar as they looked to break the deadlock against an Ivory Coast side that struggled to create clear chances of their own.
The introduction of Diallo in the 56th minute shifted the balance of the contest. His arrival allowed Yan Diomande, the Ivory Coast's standout performer throughout the match, to move to the left flank, where he created a series of dangerous opportunities.
Enner Valencia struck the woodwork for Ecuador early in the second half, but as Ivory Coast's tactical changes took hold, the South Americans lost control of a game that had been theirs to dominate in the opening 45 minutes.
The decisive moment arrived in stoppage time, when Wilfried Singo broke down the right and squared the ball across the face of goal for Diallo, who steered a first-time finish into the bottom corner to spark wild celebrations among the Ivory Coast bench and substitutes.
The result handed Ivory Coast their first World Cup victory in 12 years and moved them above Ecuador in Group E after the opening round of fixtures, behind only Germany following their 7-1 win over Curacao.
Speaking afterwards, goalscorer Amad Diallo reflected on the significance of the win and the matches still to come.
"We needed that. We came here to make history. We still have two more matches ahead of us, and we need to approach them with the same mentality and try to win them. We had to stay focused. We knew it was going to be a difficult match because we know the Ecuadorian players, they're physically very strong. They caused us problems, of course, but we stayed composed and remained focused."
Yan Diomande, named Player of the Match for his performance on the right and later the left flank, spoke about what representing Ivory Coast meant to him and his team-mates.
"We fought hard, we succeeded, and we're all delighted. It's always a pleasure to represent your country. It's tough and it's stressful because we're representing nearly 33 million people. We're playing for our families, our friends, our loved ones, and in this kind of competition we all want to give it our all. We want to win every match. We want to make our mark on history, and that's what we're all trying to do together."
For Ecuador, head coach Sebastian Beccacece was left to reflect on a missed opportunity despite his side's improved second-half showing.
"In the second half, we made the necessary adjustments and were in control enough to secure at least a draw. We put in a tremendous effort against a strong opponent. The final result wasn't what we wanted, but it's just the beginning, and we have to keep working."
With Ecuador's long unbeaten run ended in stoppage time, the South Americans now face a must-win scenario against Curacao in their next fixture, while Ivory Coast can approach their remaining group matches with the confidence of a team that has already delivered when it mattered most.