Canada's Wimbledon women's finalist Eugenie Bouchard, from Westmount, Que., was playing her second round match under the lights at Arthur Ashe stadium against Romanian Sorana Cirstea in a first-time meeting.
Raonic took his revenge after losing to Gojowczyk last June on grass in Halle, Germany, providing the German with his first career top 10 win.
World No. 6 Raonic ended with 26 aces as he heads into an upcoming match against 34-year-old tournament debutant Victor Estrella Burgos after the player from the Dominican Republic defeated 17-year-old Croatian Borna Coric by a 7-6 (2), 4-6, 6-4, 6-2 scoreline.
"It's about finding a way and getting through. That's what I was able to do," said Raonic. "I have one day now to get better and I know I'll play better my next match."
The Canadian still feels he has improvements to make in his game.
"I wasn't focusing on the right things. I got a little bit caught up," he said. "I didn't focus on my stuff. I was getting a little too caught up in him rather than focusing on myself."
Raonic, from Thornhill, Ont., improved his New York record to 8-3 as he plays for the fourth time in five years after missing 2011 after his hip surgery.
Conditions were difficult for both players in the wind, but Raonic said the weather "didn't really matter."
"You just have to deal with things as they come and find a way to win," he said. "It could have been perfectly calm today and been a different story."
Raonic took the 52-minute opening set in a tiebreaker as Gojowczyk landed a forehand long.
But the 124th-ranked German fought back to level by winning the second set after losing a 3-1 lead but breaking in the final game. Raonic answered to take a two sets to one lead as he sent over his 16th ace on set point with the clock running at almost 90 minutes on court.
Raonic needed to work to secure the win, finally going through after three hours with 46 winners and 47 unforced errors.
Earlier, Wimbledon doubles champions Vasek Pospisil of Vancouver and Jack Sock of the United States both overcame injury to reach the second round with a 6-4, 6-4 defeat of Jarkko Nieminen and Henri Kontinen.
Pospisil had been bothered by a shoulder injury during a singles loss to Simone Bolelli this week while Sock had to quit in his first-round singles with a calf injury and cramping.
Pospisil didn't even know his partner was hurt until after Sock's singles loss.
"I didn't know he had to retire," he said. "I only ran into him after his match and he told me."
As for his shoulder, Pospisil said it's improving every day.
"The problem just came at a bad time," he said. "I'm serving OK but not great yet."
The eighth seeds both played without apparent problems as they completed their efficient victory in 70 minutes. The winners broke twice from 11 chances and never faced a break point from the Finnish Davis Cup team.
Pospisil and Sock lost their previous match, the Western & Southern Open final in Cincinnati, to Bob and Mike Bryan. That ended an ATP-record run of 14 straight wins as a new team, beginning with their start together at Wimbledon in June.
The pair, which remain first and foremost dedicated to singles, are also working to reach the ATP year-end finals in London next November as a doubles team.
"We are both singles players, we're fully focused on singles," Pospisil said. "But having a chance to reach London changes things.
"We're trying to keep relaxed on court, not stressing and enjoying it. We're not putting pressure on ourselves."
Later Thursday, women's seventh seed Eugenie Bouchard plays Romania's Sorana Cirstea.