The club paid tribute to late owner Vichai Srivaddhanaprabha prior to the game after he sadly passes away in a helicopter crash last weekend, before claiming the win on an afternoon where the result was largely inconsequential.
The game's decisive moment came with 55 minutes on the clock as Gray met Ben Chilwell's centre from the left to sweep home the winner on the half-volley, before being booked for taking his shirt off and revealing a 'For Khun Vichai' message in celebration.
Every Leicester player, including goalkeeper Kasper Schmeichel, who was one of the first on the scene of the crash, ran off to celebrate the goal together, before the Leicester fans launched into a rousing rendition of the club's anthem in the 60th minute (Srivaddhanaprabha's age).
Despite the added motivation of the visitors, Cardiff anything but gifted the result to the 'Foxes' as they battled tooth and nail for a result.
Victor Camarasa rattled the bar with a free-kick for the hosts, who could have been reduced to 10 men when Sol Bamba blocked Jamie Vardy's effort with his arm.
That incident didn't prove to be decisive, though, as Leicester secured the win on an emotional day.