The 23-year-old, Ulster's Player of the Year, made his international debut for Ireland in the Six Nations game against England at Twickenham in February.
McCloskey still had a year remaining on his previous contract but had no hesitation in signing a long-term deal.
"I grew up in Ulster and it was always a dream to wear the jersey," he said.
"Despite some strong interest from other clubs, it was a fairly straightforward decision since all of my family and friends are here.
"The supporters, the facilities we have and the quality of the coaching were all factors in my decision.
"We had a disappointing finish to the season but I believe things are promising for the future and I'm excited to be part of that."
McCloskey has accumulated 42 appearances, scoring five tries, since making his debut for the province in February 2014 as a replacement in the Pro12 fixture against the Dragons.
Ulster Director of Rugby Les Kiss described McCloskey's expressed delight at McCloskey's decision to extend his stay.
"Stuart has been one of our standout performers all season. A major strength of his is his gain-line busting runs, which we used to great effect this season.
"In addition to his powerful carrying ability, his deft handling and decoy lines have also caused havoc for defences."

Dead Men Risen, written by Toby Harnden and published by Quercus, took the prize at a ceremony in Westminster and was the judges' unanimous choice.
It focuses on the death of Lt Colonel Rupert Thorneloe in 2009.
It was published in amended form after the first print run was destroyed by the MoD.
The judges said the book "takes us into the hearts and minds of the Welsh Guards in a way that is both interesting and visceral".
"It challenges every citizen of this country to examine exactly what we're asking soldiers to do in Afghanistan," the panel continued.
"Rather than offering easy answers it lets the soldiers speak for themselves."
Other awards presented included a posthumous honour for Christopher Hitchens, whose final book, Arguably, was included on the long list for the top prize.
Hitchens' widow Carol Blue accepted the award on behalf of the Vanity Fair writer.
The journalism prize was awarded to Amelia Gentleman for her work in The Guardian, while the blog award went to Rangers Tax Case - an online commentary on the ongoing financial problems at the historic Scottish football club.
The writers of the blog said they aimed to "provide the details of what Rangers FC have done, why it was illegal and what the implications are for one of the largest football clubs in Britain".
The winners were chosen from shortlists of six books, six journalists and seven bloggers, whittled down from longlists of 17 books, 12 journalists and 18 bloggers.
Each of the winners received a Â£3,000 prize.
Ulster centre Stuart McCloskey has signed a contract extension which will see him remain at Kingspan Stadium until the summer of 2019.
[NEXT_CONCEPT]
A book about the death of a British officer in Afghanistan, once pulped by the Ministry of Defence, has won the Orwell Prize for political writing.