SAN FRANCSISCO — Google will begin requiring anyone who buys ads related to federal elections in the United States through its sprawling advertising network to prove that they are citizens or lawful residents of the country. In a blog post published on Friday, Google said it would take steps to verify if people or organizations are allowed to buy political advertising and ask them to prove that they are who they say they are. It will, for example, ask a political action committee for an Internal Revenue Service-issued employer identification number, or ask an individual for government-issued identification and a Social Security number. In October, Google disclosed that the Internet Research Agency, a Russian company accused of meddling in the 2016 presidential election, had spent nearly $5,000 buying online advertising during the election cycle. Laws in the United States restrict foreign entities from running election-related ads. The new policies pertain to advertisements featuring candidates for federal office or current office holders. The rules do not apply to candidates for state or local offices. The policies also do not apply to advertisements on politically charged issues — the types of topics that foreign agents used to sow division in the American electorate ahead of the 2016 elections. “As we learn from these changes and our continued engagement with leaders and experts in the field, we’ll work to improve transparency of political issue ads and expand our coverage to a wider range of elections,” Kent Walker, a Google senior vice president and general counsel, said in the post announcing the new policies. Google and Facebook, the two dominant forces in online advertising, are tightening guidelines for election ads as they brace for this fall’s midterm races. Politicians and regulators will be watching closely to see whether those technology platforms can be used again for misinformation campaigns. Last month, Mark Zuckerberg, Facebook’s chief executive, said his company would start verifying the identity of people buying political or issue ads, starting with election ads in the United States and then expanding to other countries around the world. Under its new policies, Google said political ads would include a disclosure about who is paying for them and that it planned to publish a transparency report focused on election ads. It will also create a database of election ads that includes information on funding sources and the amount of money spent. The company said it was considering extending the new rules to other countries. Google plans to start the process of verifying political advertisers at the end of May and said the new policies would go into effect on July 10.