After a 30-year bull run that saw the Nasdaq 100 index gain nearly 4,000%, the tech-heavy benchmark suddenly turned south and lost more than 20% of its value, officially putting it in bear market territory. However, two weeks ago, the index made a remarkable U-turn that cut its deficit in half, suggesting the rout of tech stocks is over and a new bull market may be here.

With the tech sector being the best-performing group of stocks over the past month, here are two of the best companies in the space that you should be buying and holding for the long term.

Smiling friends with smartphones.

Image source: Getty Images.

1. Apple

How many times are analysts going to write Apple's (AAPL 0.27%) obituary? The supposed end of the smartphone upgrade supercycle would spell doom for Apple's future growth. After reaching a $3 trillion valuation to kick off the new year, Wall Street wonders what will be the next consumer electronics gadget that kicks shares higher.

Apple actually has a lot of options, which still include its iPhone. There is still robust demand for its iPhone 13, and the supercycle might not be anywhere near over. Wedbush analyst Dan Ives says demand for the smartphone appears to be "elongated," which should dovetail nicely with the eventual release of the iPhone 14.

Apple is reportedly also working on a subscription plan for its iPhones, according to Bloomberg, but there's also a new low-cost iPhone SE coming, as well as an iPad Air, both of which will be functional on 5G networks, along with a new Mac desktop computer and faster M1 Ultra processor.

Many industry watchers expect Apple to unveil augmented reality and virtual reality headsets this year, as well as the possibility of the often-talked about Apple Car. Whether or not that actually happens, it's clear Apple has a lot to hang its hat on in the immediate future as well as for years to come.

Two people examining computer servers.

Image source: Getty Images.

2. Microsoft

While I don't consider myself a complete Apple fanatic, I am steeped in its ecosystem, so I tend to view its business in a positive light. But I also hold Microsoft (MSFT 2.45%) in similar regard because of its solid reputation as a company that has grown into something far more than the software company Bill Gates founded, in particular its transition to the cloud and the anchoring there its Azure web services provides.

Over the past five years, Azure significantly narrowed the gap between itself and Amazon's cloud business, moving from a 14% share to 21%, while AWS remained static at 32%. The cloud represents 35% of Microsoft's revenue and was growing at a 25% clip last quarter, hitting $18.3 billion.

Arguably one of the biggest bets Microsoft is making is in gaming, with its $68.7 billion acquisition of Activision Blizzard. Already a significant contributor to the top and bottom lines, bringing the top gaming company on board along with its 25 million subscribers could make it an unbeatable boss. The tech giant itself says the acquisition "will accelerate the growth in Microsoft's gaming business across mobile, PC, console, and cloud and will provide building blocks for the metaverse," which itself is a whole other universe it is exploring.

Microsoft's stock is down 10% from where it started the year and trades at less than two times sales, while Wall Street forecasts earnings will grow at more than 17% annually for the next five years. That suggests for an investor with $3,000 to put into play, Microsoft should be on the short list for stocks you want to buy and hold.