Stoner started from the second row after Saturday's rain-affected qualifying but the Australian Honda rider took advantage of the drier conditions for the race and soon snatched the lead from Spanish team mate Dani Pedrosa.
Lorenzo, another Spaniard who won the season-opener in Qatar and started from pole position again on Sunday, pursued Stoner doggedly but could not find a way past and his challenge faded on the final lap.
"At the beginning of the race we didn't get such a good start and it was really difficult to stay out of trouble and try to stay with the front," Stoner said in an interview with Spanish television.
"When I started to push I noticed that myself and Jorge were able to take a little bit of an advantage over the others so I continued to go and continued to push," added the 26-year-old.
"It was a very, very difficult race today but to hold on for the entire race in near-enough to dry conditions was really a great day for me."
Stoner, who moved to within four points of Lorenzo in the championship standings, finished in a time of 45 minutes 33.897 seconds, with 2010 champion Lorenzo 0.947 behind.
Pedrosa was third, just over two seconds adrift of Lorenzo, with Britain's Cal Crutchlow fourth on another Yamaha, just under half a second further back.
Spaniard Pol Espargaro clinched his debut Moto2 victory in front of his home crowd earlier on Sunday in a race cut short by rain, while Italian rookie Romano Fenati showed a glimpse of his potential with a maiden Moto3 win after almost half the field crashed out.