MILAN (AP) — Inter Milan was made to pay for its profligacy as a late goal from substitute Rodrygo saw Real Madrid snatch a 1-0 win in their Champions League opener on Wednesday.

Rodrygo scored in the 89th minute with what was only Madrid’s second shot on target. Inter had peppered its opponents’ goal but been denied by a string of fantastic saves and some wayward finishing.

It was a first Champions League match back in front of its fans for Inter with more than 37,000 at San Siro, which is allowed to be at 50% capacity for games.

Sheriff Tiraspol leads Group D after beating Shakhtar Donetsk 2-0 on its Champions League group-stage debut earlier.

Inter and Madrid met in last season’s group stage, with the Spanish team winning both encounters — 3-2 at home and 2-0 at San Siro.

Inter had also won only three of its last 16 Champions League matches but it dominated from the start on Wednesday and almost took an early lead. Edin Džeko’s angled shot was parried by Madrid goalkeeper Thibaut Courtois and Milan Škriniar’s follow-up was deflected wide. The Inter defender headed the resulting corner narrowly off target.

Courtois also did well to palm away a header from Lautaro Martínez in the 19th minute.

Madrid managed a couple of incursions into the Inter penalty area but the danger was calmly cleared by the Nerazzurri.

The visitors didn’t have a shot a on target in the first half, and the closest they came was when Éder Militão headed a corner wide of the right post.

Moments later Inter had a double chance as first Martínez headed wide of the left upright and then shortly afterward Marcelo Brozović’s shot went narrowly past the same post.

Inter should have done better nine minutes into the second half. Courtois again did well to palm away Dzeko’s glancing header, Ivan Perišić missed the target from point-blank range and — after several nervy seconds — Madrid eventually managed to clear the danger.

At the other end, Madrid finally had its first shot on target in the 57th but Dani Carvajal’s attempt was at a comfortable height for Inter goalkeeper Samir Handanovič.

Madrid enjoyed more possession in the second half but did not appear a threat.

However, it snatched all three points right at the death as Eduardo Camavinga flicked the ball on for Rodrygo to volley into the bottom right corner and spark scenes of wild celebration on the Madrid bench.