U.S. government bond prices rose slightly on Tuesday as investors shifted out of stocks after a morning rally.

The price of the 10-year Treasury note rose 6.25 cents for every $100 invested. The yield was unchanged at 1.81 percent.

Earlier Tuesday, investors seemed to be pinning hopes on the European Central Bank buying government bonds of troubled countries to keep those countries' borrowing costs low. That helped convince some investors to sell Treasurys and buy stocks. The Standard & Poor's 500 index rose to its highest point in more than four years.

But by the end of the day, investors were selling stocks and buying Treasurys. The S&P 500 lost five points to close at 1,414.

Since hitting a record low of 1.39 percent July 24, the yield on the 10-year note has mostly been rising. At 1.81 percent, it is back to levels from early May.

In other trading Tuesday, the 30-year Treasury bond rose 31.25 cents for every $100 invested. Its yield fell to 2.91 percent from 2.92 percent late Monday.

The yield on the two-year note was unchanged at 0.29 percent.

The yield on the three-month Treasury bill rose to 0.10 percent from 0.08 percent.