Wehrlein moved into the lead of the race early on after passing both Jake Dennis and polesitter Maximilian Gunther, and then held off the duo in the closing laps to clinch his third victory of the season.
Lining up third at the start, Wehrlein made a rapid getaway from the cleaner side of the grid to immediately jump Dennis’ Andretti, before challenging the Maserati MSG of Gunther for the lead on the outside of Turn 1.
Wehrlein smartly backed off at that occasion to consolidate second position but kept the pressure up on his countryman, who had dominated the weekend until that point with the fastest times in each practice and qualifying session.
On lap four of 26, Wehrlein sent his Porsche down the inside of Gunther to take the lead in what turned out to be the race-winning move.
For the remainder of the race, it was Dennis who emerged as Wehrlein’s competitor, having recovered from dropping to fourth at the end of the opening lap behind Stoffel Vandoorne.
On lap 24, Dennis tried to make a move on the inside of Wehrlein into Turn 1 but the Porsche driver covered him off, forcing the Andretti driver to back off.
Over the final 12 laps of the race, Dennis remained within attacking distance of Wehrlein, with Gunther eventually falling behind the duo to turn it into a two-horse race for victory.
Wehrlein eventually managed to resist Dennis in a closely-fought last lap of the race, taking his first victory since the Diriyah double header in January by 0.477s.
Gunther finished over a second off the leading duo in third to claim his first podium of the season, with Vandoorne ending up fourth ahead of DS Penske team-mate Jean Eric Vergne.
Points leader Cassidy climbed from 10th on the grid to finish seventh at the flag on a day where the Jaguar-powered Envision lacked the pace of the frontrunners.
Cassidy was running sixth but dropped to seventh behind the Maserasti of Edoardo Mortara when he took his final attack mode on lap 25.
Antonio Felix da Costa finished eighth in the second of the two factory Porsches, while Robin Frijns picked up his first points finish of the season in ninth for Abt ahead of the leading McLaren of Jake Hughes.
In a repeat of Hyderabad, Sam Bird crashed into Jaguar team-mate Mitch Evans, pitching the Kiwi into a spin and out of the race while battling for position in the lower regions of the top 10.
Bird survived the incident and was running inside the points until contact with McLaren's Rene Rast sent him tumbling down to 21st.
Jakarta E-Prix: Full race results