Jordan Stewart marked his return to boyhood club Linfield with the only goal as the Northern Ireland champions inched closer to a Champions League meeting with Celtic.
Stewart struck with a minute of the second half remaining to earn a 1-0 win after the home side were kept out by La Forita goalkeeper Gianluca Vivan for much of the first qualifying round first leg.
The San Marino champions had looked set to go into the second leg next Tuesday with a draw after Vivan saved a second-half penalty.
But Belfast-born Stewart, who left his hometown club before playing senior football with Glentoran and Swindon, finally broke the deadlock after coming on as a substitute on the hour to make his first-team debut for the NIFL Premiership champions.
Linfield started the game brightly and could have taken the lead in the first half but for Vivan's efforts in La Forita's goal as he kept out several efforts.
The visitors almost took the lead against the run of play seven minutes before half-time when Jose Hirsch got on the end of Danilo Rinaldi's cross but his effort trickled just wide of the goal.
Linfield should have taken the lead after 64 minutes when they were awarded a penalty for Vivan's foul on Stephen Lowry but the keeper saved Aaron Burns' spot-kick.
Vivan then kept out Paul Smyth and Stewart in quick succession as Linfield piled on the pressure. With three minutes remaining Stewart shot wide from 25 yards.
But just as it looked like Linfield would have to settle for a draw, Stewart rounded the keeper to slide the ball home and give his side a valuable lead going into the second leg where they will aim to secure a second qualifying round meeting with Celtic.