LeBron James overtook his boyhood idol and inspiration, Michael Jordan, for fourth on the NBA’s all-time scoring list Wednesday, making history with a driving layup for the Los Angeles Lakers in a home loss to Denver.

The 34-year-old superstar matched the Chicago Bulls legend’s career total of 32,292 points with his first 12 of the game, then made history with 5:38 remaining in the second quarter and sank a free throw to complete a 3-point play.

“A lot of stuff I’ve done in my career – this ranks right up there at the top with winning the championship,” James said. “It’s just crazy, to be honest. It’s beyond crazy.”

During the next timeout, James went to the bench and buried his head in a towel, appearing to cry while a video tribute played on the scoreboard and he reflected upon the achievement of surpassing the icon he emulated.

“It was very emotional. A lot of things were going on inside me at the time,” he said. “I didn’t want to show what was going on behind that towel.”

Denver, led by Will Barton’s 23 points, defeated the Lakers 115-99 to pull within a game of Golden State for the Western Conference lead. The Nuggets (43-21) closed with a 26-12 run to foil a Lakers rally.

But the night belonged to James, who drew “Thank You MJ 23” on his shoes.

“For a kid from Akron, Ohio that needed inspiration and some type of positive influence, MJ was that guy for me. I watched him from afar, wanted to be like MJ,” James said. “Me and my friends, all we ever talked about was MJ. He was everything.

“You have no idea. Some days you don’t even think you’re going to make it to the next day because of the way things are going.

“Hopefully I can inspire the next kid like myself.”

Jordan and James are often compared as the best players in NBA history. James wears the same No. 23 worn by Jordan and recalled being 15 when he first met his idol.

“It was like meeting Jesus. That’s what meeting MJ was like, because I never thought I’d ever meet him,” James said. “He was like lightning in a bottle for me.

“MJ had a lot to do with me making it out (of poverty) as well as my mother. But Mike had no idea what he was doing for a kid growing up a 45-minute flight from Chicago when he was doing all that work.”

James finished with 31 points, moving his fourth-best NBA career total to 32,311, and added seven rebounds and seven assists for the Lakers (30-35).

James, the top scorer among active players, made his points in 1,190 games compared to 1,072 for Jordan.

The next target for James would be retired Lakers star guard Kobe Bryant, who is third on the NBA career list with 33,643 points. Lakers legend Kareem Abdul-Jabbar holds the NBA points record with 38,387, with long-time Utah great Karl Malone ranked second on 36,928.

On his current pace, James figures to pass Bryant next season and could overtake Abdul-Jabbar by the end of his Lakers contract in the 2021-22 campaign if he stays healthy.

James hit two 3-pointers in the first quarter but also went 0-4 from the free throw line. He added a lay-in and jumper to match Jordan early in the second quarter and then broke the record soon after.

“It was a pretty awesome moment,” Lakers coach Luke Walton said. “Knowing that moment was a few minutes ahead of him, I think that did something to him, nerve-wracking, that he doesn’t feel normally at the start of a game.”

LaVine leads Bulls win

In other games, Zach LaVine scored 39 points, making the decisive layup with 1.6 seconds remaining, and host Chicago edged Philadelphia 108-107.

LaMarcus Aldridge scored 32 points to power San Antonio over host Atlanta 111-104 and Spencer Dinwiddie netted 28 to lead Brooklyn over Cleveland 113-107.

Gordon Hayward’s jumper with two seconds remaining gave Boston a dramatic 111-109 victory at Sacramento while Bradley Beal scored 30 points to lead Washington over Dallas 132-123.

Canada’s Kelly Olynyk scored 22 points and grabbed 11 rebounds to lead Miami’s 91-84 win at Charlotte while Andre Drummond scored 31 points to lead Detroit over Minnesota 131-114.

Frenchman Rudy Gobert had 22 points and 13 rebounds to help visiting Utah over New Orleans 114-104 and Phoenix beat New York 107-96 in a duel of the NBA’s worst clubs.