Spain's government has acquired a three-percent stake in telecoms giant Telefonica following concerns over a Saudi firm taking a piece of a company that Madrid considers strategically important.