The Thornhill, Ont., native overcame 55 unforced errors including 15 double faults on Tuesday to defeat Santiago Giraldo of Colombia 6-3, 4-6, 3-6, 6-4, 6-4.
Raonic, the No. 15 seed, earned his 34th victory of the season in a match that lasted well over three hours.
"I'm just happy with the outcome and that I managed to make the most of that moment and just find a way to win," said Raonic. "Everything else I've got to hope gets better in the next round."
Raonic had 30 aces, but struggled with unforced errors and converted on only a third of his dozen break points.
"I don't think I struggled with my serve that much in a long, long time. A lot of double faults, and it wasn't just one double fault per game," said Raonic. "I double-faulted consistently a couple times in a row, and that made my job a lot more difficult and it gave him a little bit more freedom at the same time."
Raonic did not play at the U.S. Open in 2011 as he recovered from hip surgery. In 2010 as a qualifier, he was beaten by Australian Carsten Ball in his debut at a major.
On Tuesday, Raonic found himself down 2-1, but tied the match with a break in the final game of the fourth set as Giraldo fired wide.
The match finished with a Raonic break of Giraldo on a forehand error from the Colombian.
He will play Paul-Henri Mathieu of France for the first time in the second round of the tournament.
Later Tuesday, Toronto's Daniel Nestor and partner Max Mirnyi of Belarus were upset their first-round men's doubles match with American wild-cards Steve Johnson and Jack Sock 1-6, 7-6 (7-4), 6-2.
The 39-year-old Nestor had not lost this early at Flushing Meadows since 2005, a year after lifting the title with former partner Mark Knowles.
Nestor and Mirnyi, the top-ranked team, converted on three of 15 break point chances in just under two hours while losing serve twice after a runaway win in the opening set.
"That's what happens when you let a team hang around for too long," said Nestor. "This should have been over in two sets.
"I just cannot explain how our level dropped so much and without any reason after that 6-1 first set. This is really hard to take, I can't explain it."Suggest a correction