But it didn’t last. Just one quarter later, spurred on by the release of the iPhone 4S, Siri and the holiday season, Apple retook the top slot, as TechCrunch reports. But according to numbers from Strategy Analytics, the margin is a thin one: Samsung accounted for 23.5 percent of Q4 smartphone market share, while Apple edged it with 23.9 percent. Apple shipped 37 million iPhones during the quarter; Samsung shipped 36.5 million.

But that single-quarter win for Apple is punctuated by a win for all of 2011 for Samsung. In terms of global market share for all of 2011, it’s Samsung that edged Apple, 20 percent to 19 percent. And it seems to be a close two-man race at this point, with other contenders, like the once great-and-powerful Nokia, slipping to third place with 77.3 million smartphones shipped for the year and 19.6 million shipped during Q4. Nokia holds 16 percent of the global market share for smartphones for 2011 – down from 33 percent in 2010.

The story of Samsung slogging it out with Apple is greater than just what’s happening on store shelves and in online shopping carts, though. Both companies are fighting each other pretty hard in court, as well, claiming all kinds of patent infringement in an attempt to get the competitor’s devices banned in various countries around the world. Apple has won a few victories, but legally, it’s a bit of a stalemate in most places.

The most recent legal update comes from Germany, GigaOM reports, where a second Samsung suit against Apple focusing on its devices’ use of 3G technology has been dismissed by a German court. The judge in that case didn’t specify any particular reason for the decision to dismiss the case, but it’s somewhat par for the course lately – Samsung’s 3G claims seem to have been mostly defeated in Europe under fair, reasonable and non-discriminatory licensing (FRAND) rules. Apple won some early victories claiming that Samsung devices infringed on the look and feel of its iPad and iPhone, but Samsung seems to have cleared those legal hurdles by redesigning its devices in the countries where Apple has won bans.

Given that both Samsung and Apple are doing quite well, that their neck-and-neck in terms of market share and that they both have money to spend, it seems the patent fights can be expected to continue in earnest. Expect the multifaceted smartphone race to remain hot and heavy this year, with the iPhone 5 expected in the summer and Samsung’s continual march of Android phones leveraging both 4G technology and the latest Android operating system, 4.0 Ice Cream Sandwich. For both companies, the race is much too close to call just yet.