For years, Twitter has struggled to impress Wall Street investors with its lackluster user numbers.

But it turns out Twitter's numbers were even worse than had been reported.

Twitter (TWTR) revealed Thursday that it has overstated its monthly active user numbers for years by mistakenly including a segment of users from third-party applications.

"These third-party applications used Digits, a software development kit of our now-divested Fabric platform, that allowed third-party applications to send authentication messages via SMS through our systems, which did not relate to activity on the Twitter platform," the company explained in its earnings report.

As a result, Twitter revised its previously reported numbers down by 1 to 2 million users for each of the last three quarters. The error is said to date back to the fourth quarter of 2014.

Related: Twitter isn't giving Trump longer tweets, yet

However, the snafu was overshadowed by renewed user growth and the possibility of a coming milestone: profitability.

Twitter said it may be profitable in the upcoming fourth quarter, for the first time in its four years as a publicly traded company.

Under CEO Jack Dorsey's leadership, the company has gone through rounds of layoffs and killed products like Vine to cut costs.

Twitter's sales continued to decline in the quarter, falling 4% from the same period a year earlier. But the expectation is advertisers may boost spending if Twitter is able to kickstart user growth.

Twitter added 4 million users in the third quarter, after having failed to add any users in the second quarter. Twitter now has 330 million users globally.

The gains came mostly from its international markets, but Twitter (TWTR) did manage to grow its U.S. user base by 1 million as well. In the previous quarter, Twitter's U.S. audience actually shrank slightly.

Twitter chalked up the growth to marketing and product improvements. This year, Twitter has introduced new discovery tools and tested an expanded character limit to make its product more intuitive and compelling.

Twitter has also been working to better curb abuse and harassment, though with mixed results. Just this month, women around the world threatened to boycott Twitter after it temporarily suspended the account of actor Rose McGowan.

The stock spiked more than 10% in pre-market trading Thursday following the earnings report.