The social media network reported net income of US$91mln for the fourth quarter, compared to a loss of US$167mln the same period a year earlier.
Total revenue rose 2% to US$732mln from US$717mln in 2016 as advertising revenue increased 7%.
Shares surged 25% to US$26.9 each in US pre-market trade.
Since going public in November 2013, Twitter had posted losses every quarter until now.
At its last quarterly earnings in October, the company had said it could be profitable if it reached the high end of its estimates of $220mln to $240mln in adjusted EBITDA in the final three months.
The group reached an adjusted EBITDA of US$308mln in the final quarter, well ahead of its own forecasts and analysts’ estimates of US$241mln.
Twitter to tackle fake accounts
Monthly active users stood at 330 million, up 4% from a year ago but flat compared to the previous quarter, in part due to a crackdown on fake accounts and malicious activity.
Daily active users grew 12% year-on-year, marking its fifth consecutive quarter of double-digit growth.
“I’m proud of the steady progress we made in 2017, and confident in our path ahead,” said Twitter chief executive Jack Dorsey.
For the year, revenue fell 3% to US$2.4bn and the net loss narrowed to US$108mln from US$456mln in 2016. Adjusted EBITDA rose to US$862mln from US$751mln.
Twitter expects adjusted EBITDA in the first quarter to be between US$185mln and US$205mln.
Capital expenditure in 2018 is projected to be between $375mln and $450mln as it invests in improving the site and removing malicious content, spam, fake accounts.