The world number one was well below his best in the early stages and German Becker served for the opening set at 5-4.
But he could not take either of two set points and from there Djokovic took control to win 7-6 (7/2) 6-2 6-2.
The Serb did not look comfortable at all during the first set and appeared to be breathing heavily.
Djokovic used to have a lot of problems with his breathing before switching to a gluten-free diet.
He said: "It was a struggle. It was different conditions from the first match, and I knew that he's a dangerous player. If he serves well and a high percentage, he can be a dangerous player. He's very solid from the baseline.
"Obviously his movement is not as good anymore as it was, so I tried to move him around the court and open the court. That was my tactics.
"But it was very tough. There were a lot of unforced errors, very windy conditions. You couldn't really read and kind of predict where the ball was going to go, so you have to be very alert. At the start I had difficulty with my footwork.
"But I won the set and after that it was much, much better.
"I need to start the way I started in the first match, but my game is getting there. I feel that it was a big test for me today. It was a challenge, and I needed to overcome it. I'm glad I'm through in three."
Twelfth seed Tommy Haas is also through to the third round after defeating Lu Yen-hsun of Chinese Taipei 6-3 6-4 7-6 (7/3).
At 35, the German is showing some of the best form of his life, and he described the inspiration he took from seeing the likes of Andre Agassi and Jimmy Connors play at a high level well into their 30s.
He said: "It's always about being smart, about how you train and what you do off the court. And if your body allows you to do all that stuff, then it's really up to you in many ways. It takes just discipline and work.
"If you put all that together and you try your best at doing that, I think it gives you a lot of chances. If you look at some former champions, like Andre Agassi when he was 34, 35, 36, what high level he was playing, it was inspirational for me at that time.
"Other people have done it in their late 30s as well. Look at Jimmy Connors when he was 39. Those moments stick out in your brain.
"The game also has got more physical, and there is no question that the body can only take so much. As long as you keep trying and pushing as much as you can, who knows where it can take you?
"For me, it's been definitely worth every little time that I have dedicated to it."
Next up for Haas is Russian 21st seed Mikhail Youzhny, who won a surprisingly one-sided contest against Alexandr Dolgopolov 7-5 6-1 6-3.