The 19-year-old Spaniard, who beat Daniil Medvedev to win the title in Indian Wells last week, looked in top condition as he outclassed Lajovic in the first set to keep his Miami title defence on track.
But the Serb was able to provide some tension towards the end of the second set, breaking to make it 5-5 with Alcaraz paying the price for a sloppy return.
Alcaraz was 6-2 up in the tie-break, but Lajovic won the next three points before the Spaniard's big back-hand winner settled the 91-minute contest.
"Everything was under control or I thought it was but, you know, in the match it's never easy," Alcaraz said.
"The nerves came out. I made a few mistakes that I hadn't done during the whole match. So it was tough to win the match. But I'm really happy with the level that I'm playing and it was a good match," he added.
Alcaraz will face Tommy Paul in the last 16 and the American goes into that game on the back of a 12-match winning streak against Spanish players including wins over Alcaraz and Rafael Nadal last year.
"I lost the first and only match that I played against Tommy. I know that he's a really talented and really tough player, so I have to play at my best and let's see what's going to happen," said Alcaraz.
With Nadal injured and Novak Djokovic barred from entering the US due to his refusal to take a COVID vaccine, Alcaraz is the face of this tournament and the crowd was noticeably bigger on the Hard Rock Stadium court for his game.
In the front row of the crowd was Miami Heat NBA star Jimmy Butler who embraced Alcaraz after the match.
Alcaraz said that dealing with his magnified profile is something he has yet to get fully used to.
"I feel great seeing celebrities watching my matches. It's unbelievable. I feel a little bit nervous when I see a person like Jimmy and the celebrities when I was playing in the US Open," he said.
"In a certain way, I can't believe that these people enjoy watching my matches. For me, it's crazy," he said.
- Straight sets for Fritz -
American Taylor Fritz rolled into the fourth round for the third consecutive year after clinching a 6-4, 6-4 win against Canada's Denis Shapovalov.
In a hard-hitting encounter, with both players blasting from the baseline, Fritz did not face a break point during the 81-minute encounter.
Fritz has already won one tournament in Florida this year, taking the title last month at Delray Beach and in the fourth round, the American will be up against 19-year-old Holger Rune in who beat Argentine Daniel Schwartzman 6-4, 6-2.
As always at Miami, there is a large contingent of Argentine tennis fans and they were vocal in their support for Schwartzman.
But Dane Rune converted all four break points he earned in the hot afternoon sun.
“My focus was really to step in every time I could and play my game. I think there were a few rallies where I didn’t, but 95 per cent of the match was played on my terms, which was what I wanted," he said.
Dutchman Botic van de Zandschulp triumphed for the third time in four meetings with Norway's world number four Casper Ruud, emerging with a 3-6, 6-4, 6-4 victory.
The tight encounter, with a 75 minute third set, turned decisively towards Van de Zandschulp when he held to go 5-4 up with Ruud going wide at the end of a long rally.
The Dutchman sealed victory, when on match point, Ruud's soft volley found the net.
Italian Jannik Sinner continued his strong start to the year, defeating Bulgarian Grigor Dimitrov 6-3, 6-4.
It was an error-strewn match in which players hit double the number of unforced errors to winners but Sinner handled Dimitrov's second serve well as he seeks his second Miami final appearance.
Fourth-seed Daniil Medvedev moved into the fourth round after his scheduled third round opponent Alex Molcan of Slovakia withdraw from Monday's clash with a right hip injury.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)