Late Luiz free-kick seals Chelsea win
Victor Moses gave Chelsea a 12th-minute lead with a soft goal but Basel, after an uncertain opening, fought back well after the break and looked to have grabbed a deserved draw until the Brazilian curled in a free-kick from 25 metres in the fourth minute of injury time.
The goal silenced a raucous St Jakob Park which was still celebrating Fabian Schaer's penalty for the hosts, who are aiming to become the first Swiss side to reach a European final.
However, David Luiz was lucky to escape with a yellow card after a studs-up challenge on Philipp Degen late in the game. Schaer was also fortunate not to be dismissed for a late tackle on Eden Hazard.
"We played against a good team, you could see the intensity and the pace of the game but we had enough chances to score and the penalty, which was a surprise for everyone, could have made a difference," Chelsea manager Rafa Benitez told ITV.
"All around me nobody felt that it was a penalty because the ball was in the air, it was a very strange decision."
David Luiz added: "Scoring two goals here against a very good team and with the last kick of the match is amazing for us, but we have to keep our minds strong for the second leg because that is another difficult game for us."
Basel, playing their 19th match of a marathon European campaign which started away to Estonia's Flora Tallinn in the Champions League second qualifying round in mid-July, have beaten Manchester United and Bayern Munich at home in the last 18 months.
But the English Premier League start got the start they needed following a Frank Lampard corner.
Branislav Ivanovic leapt and missed the ball, distracting the defence, and Moses immediately behind him, scored with a downward header which bounced and rose into the top of the net and should have been cleared by Mohamed Elneny on the line. It was his fourth European goal of the season.
Valentin Stocker nearly levelled for Basel early in the second half as he exchanged passes with Marco Streller and evaded Lampard only to see his effort hit the foot of the post.
Chelsea replied when Fernando Torres, wearing his 'Mask of Zorro' to protect a broken nose, smashed a left foot shot against the post after Hazard survived a reckless challenge by Schaer and pulled the ball back.
Chelsea survived several scares as Basel dominated the final half hour and the hosts levelled when Cezar Azpilicueta was controversially judged to have fouled Stocker.
Schaer stepped up and confidently dispatched the penalty and the Basel hardcore fans behind goal celebrated with pyrotechnics. Both teams went for the winner and before David Luiz struck to give Chelsea a potenitally decisive lead for next week's second leg.