Massa, who was rushed out of retirement for 2017 after Valtteri Bottas jumped ship to join Mercedes, had wanted to stay with Williams but was told the team would not be making an early decision and therefore he withdrew from contention.
The British team insisted on exploring all options and gave testing time to Sirotkin, Robert Kubica and Paul Di Resta during a post-season tyre test in Abu Dhabi.
The Russian was assessed to have produced the quickest times when adjusted for fuel and tyres and will make his full F1 debut on March 25 at the Australian Grand Prix.
“To say I’m happy and proud to join such a famous team like Williams is an understatement,” Sirotkin said.
“It took a huge amount of work to get where I am, and I’m really happy and thankful to everyone involved.
“The result of our combined efforts has helped me achieve my dream, and rest assured the team can rely on me to deliver my best.”
Williams were impressed by Sirotkin in Abu Dhabi but wanted to give all candidates their full consideration.
Paddy Lowe, Williams chief technical officer, said: “We have conducted a rigorous and exhaustive driver evaluation process.
“Ultimately, Sergey impressed the team with his driving pace and talent, technical feedback and work ethic, both at the factory and trackside in Abu Dhabi.”
Kubica had been an early favourite for the seat, a move that would have represented a remarkable comeback for the pole.
His 76-race F1 career appeared to have been ended by a life-altering crash in 2011 which left him with a partially sub-amputated arm and broken bones all up his right side.
However, he returned to rallying and proved his worth in F1 car in 2017, testing for both Renault and Williams, but both teams have now turned down the chance to sign the 33-year-old.
Di Resta meanwhile was closer to the team, having worked with them for several years as a test driver.
The Scot, who previously raced in F1 for Force India, even replaced Massa at the last minute for the Hungarian Grand Prix, impressing given his lack of preparation time with the Brazilian pulling out through illness.
And he told Express Sport of his disappointment at having been told he would not be getting the seat last month.
“Absolutely [I wanted that seat] and I was only told very very late December that I wasn’t in contention any more,” Di Resta said.
“I had a couple of good years there, I would obviously have wanted to do that more.
“I had a very good test when they did the ‘driver assessment’ if you want to call it.
“I was very happy with how that came out.
“But for whatever reason… there are various other things that go [into getting] that seat.”