Facebook Inc. on Wednesday posted more than $1 billion in quarterly profit for the first time, showing the social network’s mobile strength as advertisers increasingly look to reach younger users.

Investors drove shares up nearly 13% in after-hours trading, to $106.62, giving the 12-year-old company a market capitalization greater than $300 billion.

...