Ruiz curled an outstanding away goal from the edge of the area to send Antonio Conte’s Serie A leaders to solely their second domestic defeat of the season.
Former Chelsea boss Conte was engaged throughout the half as inter didn’t fashion any clear possibilities, and they should now win in Naples next month.
AC Milan face Juventus on Thursday at the San Siro within the second semi-final.
Inter came from 2-0 all the way down to beat rivals AC at the weekend and go top of the table however they might not find a late rally on this occasion.
Ashley Young, Alexis Sanchez and Christian Eriksen were all absent from the beginning line-up and Dries Mertens and Piotr Zielinski each went close for Napoli within the half.
Away fans from the Naples region were prohibited from this match – a consequence of an incident in Dec 2018, once an inter fan died of his injuries once being knocked down by a van amid violence before a match between the perimeters.
Despite that ban, there were still many Milan-based Napoli supporters within to celebrate the winner from Ruiz.
The midfielder played a sublime one-two on the edge of the box, then bent a left-footed strike around Daniele Padelli and into the highest corner.
Eriksen and Sanchez were introduced as inter tried to reply, with on-loan Manchester United forward Sanchez failing to get a shot away once well placed and Romelu Lukaku, another former Premier League striker, seeing a scrambled effort well saved.
Eriksen then had a shot deflected wide however Napoli hung on to take the lead into the second leg, that takes place on five March.