A Liberal candidate apologized unreservedly for posting offensive tweets several years ago on Tuesday, and then several hours later said in a statement on social media she would no longer be running in the Oct. 19 election.

"After the unfolding of today's events, I have decided to step down as the Liberal candidate for Calgary Nose Hill," Ala Buzreba said in a Facebook message posted around 8:30 p.m. local time.

Buzreba earlier in the day apologized after some tweets she posted as a teenager four years ago began circulating on Twitter, apparently dug up by Conservative supporters.

The 21-year-old was to run against Conservative cabinet minister Michelle Rempel.

"The discussion shouldn`t be focused on me and my tweets, but rather it should be about what's best for Canadians," Buzreba said in the statement indicating she would be stepping down. "This election is about bringing real change to Ottawa and I firmly believe that Justin Trudeau and the Liberal team are best placed to do just that."

The development leaves the Liberals scrambling for a new candidate. The NDP will be nominating its candidate in the riding next week.

Buzreba earlier said the comments do not reflect her current thinking.

She also said she has learned a lot of lessons about social media since she posted the vitriolic comments.

In one, she tells a strident defender of Israel: "Your mother should have used that coat hanger."

In another, she tells a tweeter she deems a racist to "go blow your brains out you waste of sperm."

And in yet another, she reports that she just got her hair cut and looks "like a flipping lesbian."

Buzreba said the tweets "reflect a much younger person."

"I apologize without reservation for the comments I made a long time ago, as a teenager, but that is no excuse," she tweeted Tuesday.

"They do not reflect my views, who I am as a person, or my deep respect for all communities in our country."

Trudeau was asked about the comments during a campaign stop in Sault Ste. Marie said Buzreba made mistakes and apologized.

Justin Trudeau on Ala Buzreba0:24

"When someone makes a mistake it is important that they own up to it and they apologize. Ala has unreservedly apologized for her comments," Trudeau said.

"I think it is important to point out that she was a teenager and we all make mistakes, but I'm glad to see she has unreservedly apologized."

It's surprising the young candidate was not more internet savvy, says University of Calgary political science instructor Melanie Thomas.

"I wonder about anybody who runs for public office, knowing the context, especially the social media and internet context, who doesn't — before they actually get on the ballot — make sure their social media accounts are as bland as unsalted oatmeal," she said.

With files from CBC News